Code Monkey home page Code Monkey logo

acg's Introduction

Diversified Adversarial Attacks based on Conjugate Gradient Method

This is the python implementation of our paper, "Diversified Adversarial Attacks based on Conjugate Gradient Method" , accepted to ICML2022. paper(arxiv)



Environment

Python 3.9.8
PyTorch1.10.0+cu113
gcc gcc version >= 5.4.0
CUDA 11.5


Installation

  • Install python libraries.
pip install -r requirements.txt
  • Complie .cpp and .c codes.
cd src/utils/cluster_coef_c
python setup.py build_ext -i
  • Set ImageNet dataset.
    The directory name is the same as auto-attack

After your download, ls outputs the follow.

storage/ILSVRC2012/ILSVRC2012_img_val_for_ImageFolder/val
  • Downloads the robsust models from RobustBench.
cd src
python get_models.py

Environment Variables

export CUBLAS_WORKSPACE_CONFIG=:4096:8
  • Fix PYTHONHASHSEED to 0.
export PYTHONHASHSEED=0

Dataset

  • ImageNet

    1. cd ../storage/ILSVRC2012
    2. Download ILSVRC2012_img_val.tar and ILSVRC2012_devkit_t12.tar.gz from ImageNet official site
    $ ls
    ILSVRC2012_img_val.tar
    1. mkdir val && tar -xf ILSVRC2012_img_val.tar -C ./val

    2. tar -xzf ILSVRC2012_devkit_t12.tar.gz

    3. python build_dataset.py

Usage

Attack on CIFAR-10

python -B run_cifar10_attack.py -o ../debug -g 0 --log_level 20 --param ./params/robustbench/cifar10/autoconjugate.yaml ./params/robustbench/cifar10/di.yaml  --experiment -bs 10

Attack on ImageNet

python -B run_imagenet_attack.py -o ../debug -g 0 --log_level 20 --param ./params/robustbench/imagenet/autoconjugate.yaml ./params/robustbench/cifar10/di.yaml  --experiment -bs 10

Attack on CIFAR-100

python -B run_cifar100_attack.py  -o ../debug -g 0 --log_level 20 --param ./params/robustbench/cifar100/autoconjugate.yaml ./params/robustbench/cifar10/di.yaml  --experiment -bs 10

Calculate the attack success rates from result dir.

(find ../result/ -maxdepth 7 |grep -e AUTOP -e AUTOC | xargs -L1 -P1 python run_evaluator_from_csv.py -ns 1  -r && find ../result/ -maxdepth 7 |grep AUTOC | xargs -L1 -P1 python run_evaluator_from_csv.py -ns 5 -r ) > cifar10_cw_result.csv

and open cifar10_cw_result.csv

Ding2020MMA,AUTOConjugaterestart-1,WideResNet-28-4,\cite{Ding2019},53.40,Wed Jan 26 10:59:21 2022
Ding2020MMA,AUTOConjugate,WideResNet-28-4,\cite{Ding2019},55.77,Wed Jan 26 10:59:21 2022
  • 1st column: model name listed in RobustBench.
  • 2nd column: the algorithm name.
    AUTOConjugaterestart-1 mean ACG with one restart.
  • 3rd column: the architecture of model
  • 4th column: the citation of the adversarial training method
  • 5th column: the attack success rates
  • 6th column: the execution start time

Docker Usage

Requirements

Command

Build Docker Command

docker build --rm -t autocg:latest .

Create docker instance

docker run -it --gpus all -v $PWD/src:/AutoCG/src autocg /bin/bash

Start created container instance

docker start -ai [ContainerID]

Connect started container

docker attach [ContainerID]

Detach from Container

[control-P] [control-Q]

Citation

@inproceedings{yamamura2022,
    title={Diversified Adversarial Attacks based on Conjugate Gradient Method}, 
    author={Keiichiro Yamamura and Haruki Sato and Nariaki Tateiwa and Nozomi Hata and Toru Mitsutake and Issa Oe and Hiroki Ishikura and Katsuki Fujisawa},
    booktitle={ICML},
    year={2022}
}

acg's People

Contributors

yamamura-k avatar

Stargazers

Chunlin Qiu avatar Nariaki Tateiwa avatar trienebutdiene avatar Colorful_White avatar  avatar chenyiming avatar Ayano Ide avatar Haruki Sato avatar

Watchers

Haruki Sato avatar  avatar

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.