Adversarial training for free!

Ali Shafahi, Mahyar Najibi, Amin Ghiasi, Zheng Xu, John P. Dickerson, Christoph Studer, Larry S. Davis, Gavin Taylor, Tom Goldstein

Introduction

Deep neural networks are famously fragile: adding a tiny, imperceptible amount of calculated noise (an adversarial perturbation) to an image can trick a world-class classifier into misidentifying the subject. The most reliable defense against these malicious "noise" attacks is Adversarial Training, where the network is trained directly on these "hard" adversarial examples.

However, generating these examples typically requires an iterative process, such as Projected Gradient Descent (PGD), which involves multiple forward and backward passes through the network for every single training step. This makes training 7 to 30 times slower, rendering it nearly impossible to scale to large datasets like ImageNet without massive supercomputing clusters. This paper introduces "Free" Adversarial Training, an algorithm that recycles gradient information to update both the model and the adversarial perturbation simultaneously, achieving state-of-the-art robustness at virtually no extra computational cost.

The "Free" Training Methodology

In standard training, a backward pass is used to find how to change the model weights to lower the loss. In adversarial training, the network also needs to know how to change the input image to increase the loss. The authors propose a clever "gradient recycling" strategy to accomplish both efficiently:

  1. Simultaneous Updates: Instead of separate steps for generating attacks and updating weights, the algorithm updates the model weights and the image perturbation at the same time using the same backward pass.
  2. Minibatch Replay: To simulate the strength of a multi-step attack without the computational cost, the algorithm "replays" the same minibatch of data $m$ times in a row.
  3. Warm-Starting: The perturbation discovered at the end of one minibatch is used as the starting point for the next. This allows the "noise" to evolve into a potent attack over time.

By re-using the gradient of the loss with respect to the input—which is computed anyway during backpropagation—the overhead of adversarial training becomes negligible.

Key Insights and Results

The authors evaluated their method on CIFAR-10, CIFAR-100, and ImageNet, demonstrating that "Free" Adversarial Training moves robust training from the realm of multi-day cluster jobs to standard workstation tasks.

  • Massive Speedups: The method is 7x to 30x faster than traditional PGD adversarial training. On CIFAR-10 and CIFAR-100, it achieved robustness comparable to the much slower "Madry" PGD method. For example, on CIFAR-10, the model reached ~46% accuracy against a strong PGD-20 attack in about 13 hours—a task that usually takes days.
  • ImageNet Milestone: The authors produced the first successful robust model for ImageNet using a non-targeted formulation. Using just a single workstation with 4 GPUs, they trained a robust ResNet-50 in 2 days, maintaining 40% accuracy against PGD attacks. Previous attempts required 128 GPUs to reach similar results.
  • No Gradient Masking: Some "cheap" defenses work by simply making the gradients messy so attacks can't find a direction (gradient masking). The authors show their method actually flattens and smoothens the loss surface, meaning the model is genuinely robust.
Smoothed loss surfaces demonstrating genuine robustness without gradient masking.
  • Interpretability: Robust models trained this way develop "interpretable gradients." If you look at what the attack is trying to change, it actually looks like features of the target class (e.g., an attack trying to turn a dog into a cat will start adding cat-like features).

Limitations and The "m" Trade-off

While highly efficient, the method introduces a hyperparameter $m$ (the number of replay steps) that requires careful tuning.

Validation accuracy drops as the number of replay steps m increases.

There is a limit to how many times you can replay a minibatch. As shown above, if $m$ is too high, the model sees the same images too often in sequence. This lack of data diversity within an epoch can hurt the model's "natural" (clean) accuracy.

Furthermore, the authors noted that larger models (like ResNet-152) benefit more from adversarial training. Future work could explore how to optimize these massive models even further and investigate how "free" training handles targeted attacks, as the current paper focuses primarily on non-targeted formulations.

Summary updated

BibTeX
@inproceedings{shafahi2019adversarial,
  author = {Ali Shafahi and Mahyar Najibi and Amin Ghiasi and Zheng Xu and John P. Dickerson and Christoph Studer and Larry S. Davis and Gavin Taylor and Tom Goldstein},
  title = {{Adversarial training for free!}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=LKkXBtlJQtt},
}
Figure