Git Product home page Git Product logo

advflow's Introduction

AdvFlow

Hadi M. Dolatabadi, Sarah Erfani, and Christopher Leckie 2020

arXiv License: MIT

This is the official implementation of NeurIPS 2020 paper AdvFlow: Inconspicuous Black-box Adversarial Attacks using Normalizing Flows. A small part of this work, the Greedy AdvFlow, has been published in ICML Workshop on Invertible Neural Networks, Normalizing Flows, and Explicit Likelihood Models. A blog post explaining our approach can be found here.

Requirements

To install requirements:

pip install -r requirements.txt

Training Normalizing Flows

To train the a flow-based model, first set mode = 'pre_training', and specify all relevant variables in config.py. Once specified, run this command:

python train.py

Attack Evaluation

To perform AdvFlow black-box adversarial attack, first set the mode = 'attack' in config.py. Also, specify the dataset, target model architecture and path by setting the dataset, target_arch, and target_weight_path variables in config.py, respectively. Once specified, run:

python attack.py

for CIFAR-10, SVHN, and CelebA. For ImageNet, however, you need to run:

python attack_imagenet.py

Finally, you can run the Greedy AdvFlow by:

python attack_greedy.py

Pre-trained Models

Pre-trained flow-based models as well as some target classifiers can be found here.

Results

Fooling Adversarial Example Detectors

The primary assumption of adversarial example detectors is that the adversaries come from a different distribution than the data. Here, we attack the CIFAR-10 and SVHN classifiers defended by well-known adversarial example detectors, and show that the adversaries generated by our model can mislead them more than the similar method of NATTACK. This suggests that we have come up with adversaries that have similar distribution to the data.

Table: Area under the receiver operating characteristic curve (AUROC) and accuracy of detecting adversarial examples generated by NATTACK and AdvFlow (un. for un-trained and tr. for pre-trained NF) using LID, Mahalanobis, and Res-Flow adversarial attack detectors.

Data Metric AUROC(%) Detection Acc.(%)
Method ๐’ฉAttack AdvFlow (un.) AdvFlow (tr.) ๐’ฉAttack AdvFlow (un.) AdvFlow (tr.)
CIFAR-10 LID 78.69 84.39 57.59 72.12 77.11 55.74
Mahalanobis 97.95 99.50 66.85 95.59 97.46 62.21
Res-Flow 97.90 99.40 67.03 94.55 97.21 62.60
SVHN LID 57.70 58.92 61.11 55.60 56.43 58.21
Mahalanobis 73.17 74.67 64.72 68.20 69.46 60.88
Res-Flow 69.70 74.86 64.68 64.53 68.41 61.13

Acknowledgement

This repository is mainly built upon FrEIA, the Framework for Easily Invertible Architectures, and NATTACK. We thank the authors of these two repositories.

Citation

If you have found our code or paper beneficial to your research, please consider citing them as:

@inproceedings{dolatabadi2020advflow,
  title={AdvFlow: Inconspicuous Black-box Adversarial Attacks using Normalizing Flows},
  author={Hadi Mohaghegh Dolatabadi and Sarah Erfani and Christopher Leckie},
  booktitle = {Proceedings of the Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems ({NeurIPS})},
  year={2020}
}

advflow's People

Contributors

hmdolatabadi 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

Watchers

 avatar  avatar  avatar

advflow's Issues

About pretrained models to reproduce results

Hello,

Thank you for the codes and great work!
It seems like the pretrained models you provided are not complete.
I only saw CIFAR-10 FreeAdv-defense on wide ResNet, ImageNet FastAdv-defense on ResNet50, SVHN FreeAdv-defense ResNet.

By any chance that you can also upload all pretrained models to test on the success rate you presented in Table 2 (e.g. CIFAR-10 FastAdv, RotNetAdv..)?

name 'glow_coupling_layer' is not defined

when I run attack_imagenet.py, it occurs error like this

Traceback (most recent call last):
File "attack_imagenet.py", line 35, in
import model
File "/opt/data/private/cvpr_attack/AdvFlow/model.py", line 25, in
glow_coupling_layer, {'clamp': c.clamping, 'F_class': F_conv,
NameError: name 'glow_coupling_layer' is not defined

Could you please tell me how to sovle this problem?
Thanks a lot!

Why did you multiply epsilon_k with gradient in the code?

Dear Author

I read your paper with great interest, but I have a question about the code.

According to the equation of the parameter mu in the page 6, mu is just subtracted from the gradient.
But in your code, you implemented the update rule as follows.

mu += (c.lr / (c.n_pop * c.sigma))*(torch.matmul(z_sample.view(c.n_pop, -1).t(), A.view(-1, 1))).view(1, -1) # (lines 8 and 9 of Algorithm 1)

The code said that the gradient is multiplied by the epsilon_k, and then update mu, which is different from the equation in the page 6.

I saw that you implemented it following the Algorithm 1, but I want to know why you multiply the epsilon_k.

AttributeError: module 'config' has no attribute 'init_scale'

Traceback (most recent call last):
File "", line 1, in
File "/home/swt/pycharm-2019.3.5/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/swt/pycharm-2019.3.5/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/swt/AdvFlow/attack.py", line 32, in
import model
File "/home/swt/pycharm-2019.3.5/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/swt/AdvFlow/model.py", line 106, in
init_model(model)
File "/home/swt/AdvFlow/model.py", line 89, in init_model
param.data = c.init_scale * torch.randn(param.data.shape).cuda()
AttributeError: module 'config' has no attribute 'init_scale'


**I find 'init_scale' in 'pre_training',when I run attack why it need the attribute 'init_scale'.

"elif mode == 'pre_training':

train_from_scratch = True

workers         = 1              # Dataloader workers
batch_size      = 64             # Batch-size
n_epochs        = 350            # Number of training epochs

lr              = 1e-4           # Initial learning rate of the optimizer
decay_by        = 0.01           # Learning rate decay
weight_decay    = 1e-5           # Weight decay of the optimizer
betas           = (0.9, 0.999)   # Beta parameters of the Adam optimizer
n_its_per_epoch = 2 ** 10        # Maximum number of training iterations per epoch

do_rev          = False          # Adding the reconstruction error to the objective
do_fwd          = True           # The usual log-likelihood training

**### init_scale      = 0.03**
pre_low_lr      = 1
latent_noise    = 0.1

"

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.