Code for our ICML'19 paper: Interpreting Adversarially Trained Convolutional Neural Networks, by Tianyuan Zhang, Zhanxing Zhu.
If you want to run code on your own, I only provide codes on Caltech-256. We do not upload the dataset and trainned networks due to the fact that they are storage consuming. Training(Adversarial Training) scripts in this repo is not well writen, I suugest you to use your own scripts, or scripts provided in this repo
They are all in /code/baseline/ :
main.py, attack.py, utils.py dataset.py
main.pytrains CNNs. It contains sufficient comments to understand how to customize your trainings.attack.pyimplements PGD and FGSM attackers.utils.pyimplements SmoothGraddataset.pyimplements Saturation and Patch-shuffle operation. For style transfer, you have to use code provided in https://github.com/rgeirhos/Stylized-ImageNet/tree/master/codestAdv.pyin code/spatial-transform.adv.train/ implements Spatially transformed attack.
- Dowload the data from http://www.vision.caltech.edu/Image_Datasets/Caltech101/Caltech101.html to
/code/Caltech256/data -
cd dataand runPartition.pyto generate training set and test set. -
cd code/baselineand runmain.pyto train standard CNNs -
cd code/pgd.inf.eps8and runmain.pyto adversarially train CNNs against a$l_{\inf}$ -norm bounded PGD attacker. code in/code/Caltech256/code/pgd.l2.eps8are for$l_2$ -norm bounded adversarial training . -
gen_visual.pyandutils.pyin/code/Caltech256/code/baseline/contains code to generate salience maps.
Code for TinyImageNet, and CIAFR-10 are similar to that for Caltech-256, important python files such as main.py, utils.py, attack.py has the same name and functionallities
You still have to download the images from https://tiny-imagenet.herokuapp.com and put them to /code/TinyImageNet/data
@article{zhang2019interpreting,
title={Interpreting Adversarially Trained Convolutional Neural Networks},
author={Zhang, Tianyuan and Zhu, Zhanxing},
journal={arXiv preprint arXiv:1905.09797},
year={2019}
}
Please contact tianyuanzhang if you get any question on this paper or the code. ) (^∀^)