Better Representations via Adversarial Training in Pre-Training: A Theoretical Perspective

Yue Xing, Xiaofeng Lin, Qifan Song, Yi Xu, Belinda Zeng, Guang Cheng · DOI

Introduction

Adversarial training (AT) has long been recognized as a robust but computationally expensive defense mechanism against adversarial attacks. Recently, deep learning practitioners have observed a compelling phenomenon: adversarial robustness is contagious. When a model is pre-trained using adversarial methods, the downstream tasks derived from it often inherit this robustness, even when fine-tuned solely on "clean" data. This paper, presented at AISTATS 2024, provides a rigorous theoretical foundation for this "robustness inheritance," explaining how AT acts as a feature purifier during the pre-training phase.

The Challenge of Adversarial Training

The primary barrier to widespread adoption of adversarial training is its computational overhead. For instance, training a standard ResNet-18 on the CIFAR-10 dataset might take an hour, whereas adversarial training—which involves generating perturbations for every training example—can take upwards of 20 hours. While empirical evidence suggested that robust pre-trained models yield robust downstream models, the underlying mechanism remained poorly understood. This research fills that gap by analyzing how AT reshapes internal representations during both supervised and self-supervised (contrastive) pre-training.

Theoretical Framework: Sparse Coding and Feature Purification

To analyze this phenomenon, the authors utilize a Sparse Coding Model. In this framework, observed data $Z$ is viewed as a mixture of underlying true features $X$ and noise $\xi$. The study focuses on a two-layer neural network employing a gated activation function (similar to ReLU) designed to filter out noise.

The core contribution of the paper is the concept of Feature Purification:

  • Clean Training: In standard training, a single hidden node often learns a "mixture" of multiple features. This creates a vulnerability: an attacker can perturb one feature to influence the node's response to an entirely different feature.
  • Adversarial Training: By minimizing loss against an $L_2$ Fast Gradient Attack (FGM), AT forces each node to become "pure." Each node learns to respond to only one (or very few) distinct features.

This purification creates a "Gate Effect." In a purified network, the activation function acts as a sentinel. An adversarial attack on an inactive feature is insufficient to "open the gate" of a node, rendering the network naturally resistant to small perturbations.

Adversarial Training in Contrastive Learning

The authors extend their analysis to Contrastive Learning, a popular self-supervised method where models learn by comparing similar pairs (e.g., two crops of the same image) and dissimilar pairs (e.g., a cat vs. a truck).

A key insight here is the role of dissimilar pairs. The researchers found that adversarial training purifies the network primarily through these negative samples. While attacks on similar pairs are often naturally cancelled out by the contrastive loss function, attacks on dissimilar pairs are what force the model to refine and "clean" its feature representations to maintain distinct boundaries between classes.

Empirical Results and Robustness Inheritance

The theoretical findings were validated using synthetic simulations and standard benchmarks including CIFAR-10, CIFAR-100, and Tiny-ImageNet.

Key Findings:

  1. Inheritance in Action: On CIFAR-10, a model with clean pre-training and clean downstream training exhibited nearly 0% robustness against adversarial attacks. In contrast, a model with adversarial pre-training followed by clean downstream training achieved approximately 43% robustness.
  2. Accuracy Trade-offs: While AT typically incurs a "robustness tax" (a slight decrease in standard accuracy), the purified representations remained highly effective for clean tasks, showing only marginal performance drops compared to the significant gains in security.
  3. Visual Evidence: Visualization of learned convolutional filters supported the purification theory. Filters from adversarial pre-training appeared significantly "cleaner" and more concentrated on specific structures, whereas clean training filters were noisier and more dispersed.

Conclusion and Future Directions

This work demonstrates that the benefits of adversarial training extend far beyond the initial training set. By purifying the feature space, AT provides a robust foundation that downstream users can leverage with minimal additional cost.

However, several avenues for future research remain. The current theoretical proofs are centered on two-layer networks; extending these proofs to deep, multi-layer architectures like ResNets is a significant next step. Additionally, the study assumes downstream tasks are linear adaptations of pre-trained features. Future work may explore how "full fine-tuning" impacts the persistence of purified features.

Summary updated

BibTeX
@inproceedings{xing2024better,
  author = {Yue Xing and Xiaofeng Lin and Qifan Song and Yi Xu and Belinda Zeng and Guang Cheng},
  title = {{Better Representations via Adversarial Training in Pre-Training: A Theoretical Perspective}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2024},
  url = {https://openreview.net/forum?id=74nlGBxOSZ},
}
Figure