NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

On the Duality Between Sharpness-Aware Minimization and Adversarial Training

Yihao Zhang, Hangzhou He, Jingyu Zhu, Huanran Chen, Yifei Wang, Zeming Wei

Abstract

This research uncovers a fundamental "duality" between Sharpness-Aware Minimization (SAM) and Adversarial Training (AT). While AT perturbs input data and SAM perturbs model weights, both techniques implicitly encourage the model to prioritize "robust features." We demonstrate that SAM, originally intended to improve generalization, significantly boosts adversarial robustness without the substantial drop in clean accuracy typically observed with AT.

Introduction

Deep neural networks (DNNs) are notoriously fragile; small, intentional perturbations to an input—adversarial attacks—can easily flip a model's prediction. Adversarial Training (AT) is the standard defense, involving training on perturbed examples. However, AT imposes a significant "tax" by degrading performance on clean, unperturbed data. Conversely, Sharpness-Aware Minimization (SAM) seeks "flat" minima in the loss landscape to improve generalization. This paper explores the connection between these two paradigms, asking if SAM's weight-perturbation approach can effectively defend against input-perturbation attacks.

Methodology

The authors establish a relationship between SAM and AT through a unified optimization framework and theoretical analysis.

Unified Formulation

By rewriting the optimization objectives, the authors reveal a structural symmetry. AT minimizes loss under worst-case input perturbations ($\delta$), whereas SAM minimizes loss under worst-case weight perturbations ($\epsilon$).

Theoretical Analysis

Using a binary classification model, the authors decompose data into "robust features" (stable but difficult to learn) and "non-robust features" (predictive but easily manipulated). They introduce the Robust Feature Weight ($W_R$) metric to quantify a model's reliance on stable features. Theoretically, both SAM and AT are shown to increase $W_R$, forcing the model to ignore non-robust features that lead to sharp minima or adversarial vulnerability.

Experimental Results

The study includes a comprehensive experimental sweep across image classification (CIFAR-10/100, Tiny-ImageNet), corruption robustness (CIFAR-10C), semantic segmentation, and text classification.

The Robustness-Accuracy Trade-off

A key finding is that SAM provides a superior trade-off between clean accuracy and adversarial robustness compared to traditional AT.

Table 1: Comparison of clean and robust accuracy (AutoAttack) on CIFAR-100. SAM improves both metrics relative to Adam, while AT significantly degrades clean accuracy.

As shown in the table above, switching from Adam to SAM on CIFAR-100 improved robust accuracy from 3.4% to 25.4%, while simultaneously increasing clean accuracy from 76.0% to 78.7%. While AT achieves higher absolute robustness (~50%), it causes clean accuracy to plummet to approximately 60%.

Generalization Across Architectures

The benefits of SAM are consistent across various model architectures, including ResNets and Vision Transformers (DeiT).

Table 2: Performance of SAM across different architectures. SAM consistently improves natural accuracy and robustness (AA and StAdv) compared to standard SGD training.

Key Insights

  • Implicit Regularization: Perturbing weights acts as an implicit regularizer for the feature space. By making the model robust to parameter changes, it naturally becomes less sensitive to input feature changes.
  • SAM as a "Lightweight" AT: SAM serves as a moderate approach that maintains the natural data distribution while encouraging stable representations, unlike AT which "brute forces" robustness by distorting the training distribution.
  • Cross-Modality Success: Robustness gains extend beyond images to semantic segmentation and NLP tasks, where SAM-trained models exhibit lower Attack Success Rates (ASR). SAM-based models also significantly outperformed AT on the CIFAR-10C corruption benchmark (e.g., ASAM achieving 36.69% vs 15.67% for $\ell_\infty$-AT).

Conclusion

SAM offers a computationally efficient and performance-preserving alternative to traditional Adversarial Training. While it does not yet reach the absolute defensive levels of full AT, its ability to boost robustness without sacrificing clean accuracy makes it highly attractive for real-world deployment. Future work may explore increasing SAM's perturbation strength ($\rho$) to further bridge the gap to AT.

Summary updated

BibTeX
@inproceedings{zhang2024duality,
  author = {Yihao Zhang and Hangzhou He and Jingyu Zhu and Huanran Chen and Yifei Wang and Zeming Wei},
  title = {{On the Duality Between Sharpness-Aware Minimization and Adversarial Training}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=2B2U5kkGUA},
}
Figure