Learning to Defend by Learning to Attack

Haoming Jiang, Zhehui Chen, Yuyang Shi, Bo Dai, Tuo Zhao

Abstract

Adversarial training provides a principled approach for training robust neural networks. From an optimization perspective, adversarial training is essentially solving a bilevel optimization problem. The leader problem is trying to learn a robust classifier, while the follower maximization is trying to generate adversarial samples. Unfortunately, such a bilevel problem is difficult to solve due to its highly complicated structure. This work proposes a new adversarial training method based on a generic learning-to-learn (L2L) framework. Specifically, instead of applying existing hand-designed algorithms for the inner problem, we learn an optimizer, which is parametrized as a convolutional neural network. At the same time, a robust classifier is learned to defense the adversarial attack generated by the learned optimizer. Experiments over CIFAR-10 and CIFAR-100 datasets demonstrate that L2L outperforms existing adversarial training methods in both classification accuracy and computational efficiency. Moreover, our L2L framework can be extended to generative adversarial imitation learning and stabilize the training.

The Challenge of Bilevel Optimization

Deep learning models are notoriously brittle; a tiny, invisible perturbation to an image (an "adversarial attack") can trick a state-of-the-art classifier into misclassifying an object. To address this, researchers use adversarial training, which is framed as a "min-max" or bilevel optimization problem:

  1. The Follower (Attacker): Tries to find the worst-case perturbation to maximize the model's loss.
  2. The Leader (Classifier): Tries to minimize that loss to become robust.

Traditionally, the "Follower" problem is solved using hand-designed, iterative algorithms like the Projected Gradient Method (PGM/PGD). However, these are computationally expensive—requiring many gradient steps per image—and may not find the most effective perturbations. These "hard-coded" attackers create a bottleneck for both the efficiency and the ultimate security of the model.

The L2L Framework

The core innovation of this work is replacing the hand-designed attack algorithm with a learned optimizer. Instead of running a loop of 20+ gradient steps, the classifier generates perturbations through a dedicated attacker network.

The L2L framework workflow showing the interaction between the Attacker network and the Classifier.

Methodology Components

  • The Attacker Network ($g_\phi$): Parameterized as a Convolutional Neural Network (CNN), the attacker generates perturbations in a single forward pass.
  • Gradient-Aware Inputs: The most effective version, the Gradient Attacker, takes both the original image $x$ and the gradient of the loss $\nabla_x \ell$ as inputs. This allows the attacker to "see" where the model is currently most vulnerable.
  • Multi-Step RNN: To mimic iterative attacks, the authors also propose a Multi-Step Gradient Attacker using a Recurrent Neural Network (RNN) structure, allowing the attacker to refine its perturbation over a few steps while remaining fully differentiable.
  • Joint Training: The classifier and the attacker are trained together. This setup is reminiscent of a Generative Adversarial Network (GAN), but rather than generating images from noise, the attacker learns a transformation to specifically "break" the classifier it is facing.

Key Results and Insights

The researchers evaluated their framework on CIFAR-10 and CIFAR-100 benchmarks using a Wide Residual Network (WRN-34-10) as the base classifier.

Comparison of PGM Accuracy and Accuracy Difference across varying iterations and perturbation magnitudes.
  • Superior Robustness: On CIFAR-10, the "2-Step L2L" method achieved a robust accuracy of 54.32% against PGM-20 attacks, significantly outperforming the standard PGM Net (47.04%).
  • Computational Efficiency: By training a network to attack, the computational burden is "amortized." Generating a sample is a fast forward pass through a CNN. On CIFAR-10, PGM training took ~1310 seconds per epoch, while the Gradient L2L took only ~617 seconds—a 2x speedup.
  • Structural Learning: Unlike PGD, which treats every image as an independent optimization problem, the L2L attacker learns common structures of vulnerability across the entire dataset. It learns general strategies for attacking specific classes rather than starting from scratch for every image.
  • Generalization: Models defended by L2L showed strong resistance not just to the L2L attacker, but also to "unseen" attacks like the Carlini-Wagner (CW) attack and random noise.

Conclusion and Future Directions

By "learning to attack," the L2L framework provides a more efficient and robust path to adversarial defense. While the results on CIFAR are impressive, future work remains in scaling these architectures to larger datasets like ImageNet, where memory overhead for dual networks is more significant. Additionally, while L2L simplifies execution, the underlying bilevel optimization remains theoretically complex, and future research may focus on providing stronger convergence guarantees for this meta-learning approach.

Summary updated

BibTeX
@inproceedings{jiang2021learning,
  author = {Haoming Jiang and Zhehui Chen and Yuyang Shi and Bo Dai and Tuo Zhao},
  title = {{Learning to Defend by Learning to Attack}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2021},
  url = {https://openreview.net/forum?id=HVnZk2X9cl9},
}
Figure