This repo provides the PyTorch code for both vanilla training and adversarial training deep neural networks.
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
A brief description on how to train and attack the model.
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.
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.
- python 3.6
- PyTorch 1.7.0
- AdverTorch 0.2.3
If u find the codes useful, welcome to fork and star this repo :)