Friendly Sharpness-Aware Minimization

Tao Li, Pan Zhou, Zhengbao He, Xinwen Cheng, Xiaolin Huang
2/9/2026

No official code found. Best implementation: nblt/F-SAM (37 stars, last commit 2024-10-29). 1 more below.

Abstract

Sharpness-Aware Minimization (SAM) has been instrumental in improving deep neural network training by minimizing both training loss and loss sharpness. Despite the practical success, the mechanisms behind SAM's generalization enhancements remain elusive, limiting its progress in deep learning optimization. In this work, we investigate SAM's core components for generalization improvement and introduce “Friendly-SAM” (F-SAM) to further enhance SAM's generalization. Our investigation reveals the key role of batch-specific stochastic gradient noise within the adversarial perturbation, i.e., the current minibatcli gradient, which significantly influences SAM's generalization performance. By decomposing the adversarial perturbation in SAM into full gradient and stochastic gradient noise components, we discover that relying solely on the full gradient component degrades generalization while excluding it leads to improved performance. The possible reason lies in the full gradient component's increase in sharpness loss for the entire dataset, creating inconsistencies with the subsequent sharpness minimization step solely on the current minibatcli data. Inspired by these insights, F-SAM aims to mitigate the negative effects of the full gradient component. It removes the full gradient estimated by an exponentially moving average (EMA) of historical stochastic gradients, and then leverages stochastic gradient noise for improved generalization. Moreover, we provide theoretical validation for the EMA approximation and prove the convergence of F-SAM on non-convex problems. Extensive experiments demonstrate the superior generalization performance and robustness of F-SAM over vanilla SAM. Code is available at https://github.com/nblt/F-SAM.

View on arXivView PDF

Code Implementations(2)

nblt/F-SAMCommunity72%

[CVPR 2024] Friendly Sharpness-Aware Minimization

375Shell, PythonMar 14, 20241 years ago

Single-Step Friendly Sharpness Aware Minimization

00PythonDec 29, 20259 months ago

Similar Papers

Cite this paper

@article{li2026friendly,
  title  = {Friendly Sharpness-Aware Minimization},
  author = {Tao Li and Pan Zhou and Zhengbao He and Xinwen Cheng and Xiaolin Huang},
  year   = {2026},
  eprint = {2403.12350},
  archivePrefix = {arXiv},
  url    = {https://ink.library.smu.edu.sg/context/sis_research/article/10021/viewcontent/2024_CVPR_FSAM.pdf},
  journal = {CVPR 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2403.12350.svg)](https://codeofpaper.com/paper/2403.12350)

Discussion