Code Monkey home page Code Monkey logo

dverge's Introduction

DVERGE

This repository contains code for reproducing our NeurIPS 2020 Oral paper "DVERGE: Diversifying Vulnerabilities for Enhanced Robust Generation of Ensembles".

Dependencies

Create the conda environment called dverge containing all the dependencies by running

conda env create -f environment.yml

We were using PyTorch 1.4.0 for all the experiments. You may want to install other versions of PyTorch according to the cuda version of your computer/server. The code is run and tested on a single TITAN Xp GPU. Running on multiple GPUs with parallelism may need adjustments.

Data and pre-trained models

The pre-trained models and generated black-box transfer adversarial examples can be accessed via this link. Specifically, the pre-trained models are stored in the folder named checkpoints. Download and put checkpoints under this repo.

The black-box transfer adversarial examples (refer to the paper for more details) are stored in transfer_adv_examples.zip. Make a folder named data under this repo. Download the zip file, unzip it, and put the extracted folder transfer_adv_examples/ under data/. Then one can evaluate the black-box transfer robustness of ensembles.

Usage

Examples of training and evaluation scripts can be found in scripts/training.sh and scripts/evaluation.sh.

Note that for now we extract models' intermediate features in a very naive way which may only support the ResNet20 architecture. One can implement a more robust feature extraction with the help of forward hook of Pytorch.

Also, you may observe a high variation in results when training DVERGE, which we suspect is due to the random layer sampling for distillation. Please refer to Appendix C.5 of the paper for a discussion on the layer effects.

Decision region plot

We have been receiving many questions regarding the decision region plot in Figure 1. To understand how it works, a neat working example can be found in the "What is happening with these robust models?" section in this fantastic tutorial. Our code is adapted from that example, and the only difference is that while they plot the loss, we plot the model's decision/predicted class. Our code can be found here. It is pretty messy, yet the essential part starts from line 177. When plotting Figure 1, we use args.steps=1000 and args.vmax=0.1, which means that we are perturbing along each direction by a maximum of distance of 0.1, and along each direction we sample 1000 perturbations and record the model's decision on each of the corresponding perturbed sample. So totally we sample 1000*1000 data points to make each of the plot in Figure 1.

Reference

If you find our paper/this repo useful for your research, please consider citing our work.

@article{yang2020dverge,
  title={DVERGE: Diversifying Vulnerabilities for Enhanced Robust Generation of Ensembles},
  author={Yang, Huanrui and Zhang, Jingyang and Dong, Hongliang and Inkawhich, Nathan and Gardner, Andrew and Touchet, Andrew and Wilkes, Wesley and Berry, Heath and Li, Hai},
  journal={Advances in Neural Information Processing Systems},
  volume={33},
  year={2020}
}

Acknowledgement

The training code of ADP (Adaptive Diversity Promoting Regularizer) is adapted from the official repo, which is originally written in TensorFlow and we turned it into Pytorch here.

dverge's People

Contributors

zjysteven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dverge's Issues

Code for decision region plots

Hi @zjysteven, thanks for this insightful work!

I was wondering if you could provide the code that produces the decision region plots that are shown in the paper (Figure 1, 7)? Some of the details of these plots are unclear to me:

  1. From the paper, I understand that the vertical axis is along the adversarial direction and the horizontal axis along the direction of a random Rademacher vector. What do the values of these axis represent exactly?
  2. How are the adversarial direction and the random Rademacher vector combined to obtain the final sample for which the model then produces the label being plotted in the decision region plot?

I think uploading the plotting code would help to better understand these plots 🙂

on calculate the robustness value(AdvT Rob)

Thank you for your wonderful research. Please tell me how to calculate the robustness value of adversarial training (as shown in the figure below, AdvT Rob)? Since I didn't read the code carefully, I didn't find it in the relevant code.Thanks.
image

Concerns on the generalization performance of the ensemble after using DVERGE

Hi @zjysteven, thanks for this solid and insightful work!

We are kind of interested in the generalization performance after using DVERGE (i.e., classification error on the clean dataset instead of robustness against adversarial samples), and I will appreciate it very much if you could share some results or ideas.

FYI, here is a paper saying that adversatial training also improves the generalization performance: B. Lakshminarayanan, A. Pritzel, C. Blundell., Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles, NIPS 2017. However, our experiment results are not quite satisfactory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.