Skip to content

Latest commit

 

History

History

README.md

Fast Adversarial Training

This is a supplemental material containing the code to run Fast is better than free: revisiting adversarial training, submitted to ICLR 2020.

The framework used is a modified version of the Free Adversarial Training repository, which in turn was adapted from the official PyTorch repository.

Installation

  1. Install PyTorch.
  2. Install the required python packages. All packages can be installed by running the following command:
pip install -r requirements.txt
  1. Download and prepare the ImageNet dataset. You can use this script, provided by the PyTorch repository, to move the validation subset to the labeled subfolders.
  2. Prepare resized versions of the ImageNet dataset, you can use resize.py provided in this repository.
  3. Install Apex to use half precision speedup.

Training a model

Scripts to robustly train an ImageNet classifier for epsilon radii of 2/255 and 4/255 are provided in run_fast_2px.sh and run_fast_4px.sh. These run the main code module main_free.py using the configurations provided in the configs/ folder. To run the 50 step PGD adversary with 10 restarts, we also provide run_eval.sh. All parameters can be modified by adjusting the configuration files in the configs/ folder.

Model weights

We also provide the model weights after training with these scripts, which can be found in this Google drive folder. To use these with the provided evaluation script, either adjust the path to the model weights in the run_eval.sh script or rename the provided model weights accordingly.