fanghenshaometeor / vanilla-adversarial-training

vanilla training and adversarial training in PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vanilla-adversarial-training

This repo provides the PyTorch code for both vanilla training and adversarial training deep neural networks.

What

A brief description for the files in this repo:

train.py,.sh : training python and shell scripts

attack.py,.sh : attack python and shell scripts

utils.py : utility functions

model/ : model definitions directory

How

A brief description on how to train and attack the model.

Training

To reproduce the training, users can run the train.sh shell scripts directly on the command line.

sh train.sh

Detailed training settings (model architecture, data set and whether to perform adversarial training) could be specified freely in the train.sh script.

Attack

To attack the model, users can run the attack.sh shell scripts directly on the command line.

sh attack.sh

Detailed attacking settings could be specified freely by commenting some lines in the attack.sh script.

ATTENTION

  • The mean-var normalization preprocess is included in the model definitions.
  • The adversarial training is PGD-based: bound $l_\infty=8/255(0.031)$, step-size $2/255$ and $10$ iterations.
  • In adversarial training, the network prameters are updated with adversarial examples only.
  • The model is trained for $200$ epochs and the last model is selected.

Dependencies

  • python 3.6
  • PyTorch 1.7.0
  • AdverTorch 0.2.3

If u find the codes useful, welcome to fork and star this repo :)

About

vanilla training and adversarial training in PyTorch


Languages

Language:Python 96.7%Language:Shell 3.3%