Adversarial Training with Stochastic Weight Average

Joong-Won Hwang, Youngwan Lee, Sungchan Oh, Yuseok Bae

Abstract

Adversarial training (AT) is the primary defense against adversarial attacks, yet it is plagued by overfitting and significant computational demands. This paper introduces Stochastic Weight Average based Adversarial Training (SWAAT), a technique that averages model weights during training to simulate an ensemble's benefits. By finding flatter regions in the loss landscape, SWAAT enhances robustness and generalization while maintaining the efficiency of a single model.

Introduction

Deep Learning models are notoriously fragile; small, intentional perturbations to an input (adversarial attacks) can easily fool them. Adversarial Training (AT)—where a model is trained on these "attack" images—is the most effective defense. However, AT requires significantly more data than standard training to generalize well. Without sufficient data, models often "memorize" specific attacks, leading to poor performance on unseen perturbations.

The Dilemma of Decoupling

A common strategy to reduce overfitting is ensembling multiple models. However, applying ensembling to AT introduces a "Dilemma of Decoupling." As illustrated in Figure 1, if adversarial examples are generated against individual models (a), the ensemble as a whole remains vulnerable. If they are generated against the entire ensemble (b), the individual models become weak and lose the diversity necessary for a robust ensemble. This conflict makes traditional ensembling difficult to optimize for adversarial robustness.

The Dilemma of Decoupling in adversarial training for ensembles.

The SWAAT Method

To resolve this dilemma, the authors propose SWAAT (Stochastic Weight Average based Adversarial Training). SWAAT treats the training process as a "temporal ensemble," averaging model weights across iterations to find a flatter, more generalizable region of the loss landscape.

Key components of SWAAT include:

  • Continuous Aggregation: Weights are aggregated after every iteration, and the active model is updated with this average at the end of every epoch.
  • Coupled Adversarial Generation: Because the model is an ensemble in time, adversarial examples generated during training are naturally coupled with the averaged model, bypassing the decoupling dilemma.
  • BN Statistic Recalculation: Weight averaging can mismatch Batch Normalization (BN) statistics. SWAAT recalculates these using natural images, which surprisingly proves as effective as using adversarial images while saving computation.
  • Hard Example Mining (HEM): To maintain diversity in the temporal ensemble, SWAAT uses HEM to identify difficult images and increase their frequency in subsequent training epochs.

Experimental Results

SWAAT was evaluated on CIFAR-10, CIFAR-100, and SVHN using Pre-activation ResNet18 and WideResNet-28-10 architectures. As shown in the results table below, SWAAT consistently outperforms standard PGD-based adversarial training and other state-of-the-art defenses.

Comparison of SWAAT against state-of-the-art adversarial defense methods across multiple datasets.

On CIFAR-10 with a WideResNet-28-10, SWAAT achieved 60.57% accuracy against a PGD-20 attack, compared to 56.23% for standard PGD-AT. Similar improvements were noted for CIFAR-100 (reaching 31.07% robustness) and SVHN (improving from 58.50% to 61.48%). Crucially, the model passed the "Obfuscated Gradient Test," confirming that its robustness is genuine and not a result of gradient masking.

Conclusion

SWAAT provides the performance benefits of an ensemble—higher robustness and better generalization—without the massive overhead of training and storing multiple networks. By moving the model toward flatter minima, it addresses the core overfitting issues of adversarial training. While the Hard Example Mining strategy adds some computational cost, the resulting gains in robustness make SWAAT a powerful tool for securing deep learning models.

Summary updated

BibTeX
@inproceedings{hwang2021adversarial,
  author = {Joong-Won Hwang and Youngwan Lee and Sungchan Oh and Yuseok Bae},
  title = {{Adversarial Training with Stochastic Weight Average}},
  booktitle = {ICIP},
  year = {2021},
  doi = {10.1109/icip42928.2021.9506548},
}
Figure