GithubHelp home page GithubHelp logo

mickey-lyx / atta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haizhongzheng/atta

0.0 0.0 0.0 15 KB

ATTA (Efficient Adversarial Training with Transferable Adversarial Examples)

License: Other

Python 100.00%

atta's Introduction

ATTA (Efficient Adversarial Training with Transferable Adversarial Examples)

Code for CVPR'2020 paper: Efficient Adversarial Training with Transferable Adversarial Examples.

Prerequisites

  • Python 3.6.3
  • Pytorch 1.2.0, torchvision 0.4.0
  • Numpy 1.13.3

Code Overview

The directory models contains model architecture definition files. The directory data-config contains different config files to train the model and the directory data-model is used to contain model checkpoints.

Other seven Python scripts are used to train and evaluate the ATTA model.

  • train_atta_mnist.py: trains ATTA models on MNIST dataset.
  • train_atta_cifar.py: trains ATTA models on CIFAR10 dataset.
  • cifar_dataloader.py: loads the padded data of CIFAR10.
  • adv_attack.py: generates accumulative adversarial examples for the training of ATTA.
  • adaptive_data_aug.py: performs data augmentation and inverse data augmentation for ATTA.
  • pgd_attack_mnist.py: performs PGD-k attack on MNIST models.
  • pgd_attack_cifar10.py: performs PGD-k attack on CIFAR10 models.

Simple instructions to train and evaluate models

Train a model:

#MNIST

python train_atta_mnist.py --config-file [config_file_name] --gpuid [GPU_ID]


#CIFAR10

python train_atta_cifar.py --config-file [config_file_name] --gpuid [GPU_ID]

Attack a model:

#MNIST

python pgd_attack_mnist.py --model-dir [path of model] --gpuid [GPU_ID]


#CIFAR10

python pgd_attack_cifar10.py --model-dir [path of model] --gpuid [GPU_ID]

Naming rule for configuration files in data-config:

[dataset]-atta-[the number of attack iterations]-[training method].json

data-config/mnist-atta-1-mat.json means that model will be trained with MAT(ATTA-1) on MNIST.

Examples for training and evaluate:

  • TRADES(ATTA-1) on MNIST:
python train_atta_mnist.py --config-file data-config/mnist-atta-1-trades.json --gpuid 0

python pgd_attack_mnist.py --model-dir data-model/mnist-trades-atta-1/model-mnist-epoch60.pt --gpuid 0
  • MAT(ATTA-1) on CIFAR10:
python train_atta_cifar.py --config-file data-config/cifar-atta-1-mat.json --gpuid 0

python pgd_attack_cifar10.py --model-dir data-model/cifar-mat-atta-1/model-cifar-epoch38.pt --gpuid 0

Reference

@inproceedings{zheng2020efficient,
 author={Zheng, Haizhong and Zhang, Ziqi and Gu, Juncheng and Lee, Honglak and Prakash, Atul},
 title={Efficient Adversarial Training with Transferable Adversarial Examples},
 BOOKTITLE = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
 YEAR = {2020}
}

Credit: The implementation of ATTA is based on TRADES code.

atta's People

Contributors

neuer93 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.