Sharpness-Aware Minimization Revisited: Weighted Sharpness as a Regularization Term

Yun Yue, Jiadi Jiang, Zhiling Ye, Ning Gao, Yongchao Liu, Ke Zhang

Abstract

Sharpness-Aware Minimization (SAM) has emerged as a powerful optimization technique for deep learning, focusing on finding flat minima to improve generalization. However, the standard SAM formulation treats the training loss and the sharpness term as equal components. This paper introduces Weighted Sharpness-Aware Minimization (WSAM), a novel framework that treats sharpness as a tunable regularization term. By decoupling the sharpness weight and introducing a specialized update rule, WSAM achieves superior generalization and enhanced robustness to label noise across multiple computer vision benchmarks.

1. Introduction

In the pursuit of deep learning models that generalize well to unseen data, the geometry of the loss landscape has become a focal point of research. It is widely accepted that models residing in "flat" regions of the loss landscape—where small perturbations to model weights do not lead to significant increases in error—generalize better than those in "sharp" valleys.

Sharpness-Aware Minimization (SAM) was developed to explicitly seek these flat minima. While effective, the original SAM formulation implicitly assumes a fixed 1:1 ratio between the standard training loss and the sharpness component. This paper argues that this fixed trade-off is often suboptimal. We propose WSAM, which allows for a more flexible and theoretically grounded approach to sharpness-aware optimization.

2. The WSAM Framework

2.1 Weighted Sharpness Objective

WSAM introduces a hyperparameter, $\gamma$, to control the influence of the sharpness term. The redefined objective function allows practitioners to tune the flatness trade-off based on the specific requirements of the task. When $\gamma > 0.5$, the optimizer prioritizes flatness more aggressively than standard SAM; conversely, $\gamma < 0.5$ shifts the focus toward minimizing the vanilla training loss. Our empirical analysis suggests that the optimal value for $\gamma$ typically lies between 0.8 and 0.95, indicating that standard SAM often under-weights the importance of sharpness.

2.2 Decoupled Update Rule

Inspired by the success of decoupled weight decay (as seen in AdamW), WSAM introduces a "weight decoupling" mechanism for the sharpness gradient. In standard SAM implementations, the sharpness gradient is often incorporated into the base optimizer's internal state (e.g., momentum). WSAM decouples this process: the sharpness regularization is calculated independently and added only during the final update step. This ensures that the regularization reflects the local geometry of the current step rather than a moving average of previous gradients, leading to more precise navigation of the loss landscape.

3. Theoretical Foundations

The authors provide a rigorous theoretical basis for WSAM, offering convergence guarantees for both convex and non-convex settings. Furthermore, using PAC-Bayesian theory, the paper demonstrates that WSAM leads to tighter generalization bounds compared to standard SAM. This theoretical framework supports the empirical observation that decoupling and weighting the sharpness term provides a more robust path to generalization.

4. Experimental Evaluation

4.1 Performance on Standard Benchmarks

WSAM was evaluated against several state-of-the-art optimizers, including vanilla SGD, SAM, GSAM, and ESAM, using CIFAR-10, CIFAR-100, and ImageNet.

  • CIFAR-100: Utilizing a WideResNet-28-10 architecture, WSAM achieved a top-1 error of 16.33%, outperforming both vanilla SAM (16.49%) and GSAM (16.36%).
  • ImageNet: In fine-tuning experiments with a pre-trained DeiT-Base (Vision Transformer), WSAM consistently demonstrated superior performance, validating its efficacy in large-scale transformer-based architectures.

4.2 Robustness to Label Noise

One of the most striking advantages of WSAM is its resilience to "dirty" data. The researchers tested the optimizer on CIFAR-10 with label noise ranging from 20% to 80%. At the extreme end (80% noise), WSAM maintained an accuracy of 78.30%. In comparison, vanilla SAM achieved 77.57%, while other variants like ESAM collapsed entirely, dropping to 32.29%. The stronger focus on flatness in WSAM appears to prevent the model from memorizing the sharp, erratic gradients typically associated with mislabeled data.

5. Discussion and Limitations

Minima analysis reveals that WSAM does not merely find a different trade-off point; it often discovers minima that possess both lower loss and comparable sharpness to those found by SAM. This suggests that the decoupled update allows for more effective navigation of the landscape.

However, a gap remains between the theoretical proofs and practical implementation. The convergence proofs assume that the neighborhood size $\rho$ (the radius for sharpness calculation) decreases over time, whereas in practice, $\rho$ is held constant. Additionally, while $\gamma$ is relatively stable across tasks, it introduces an additional hyperparameter that requires tuning. Future work will focus on bridging the theoretical gap for constant $\rho$ and exploring automated methods for $\gamma$ selection.

6. Conclusion

WSAM reframes sharpness-aware optimization by treating flatness as a tunable regularization term. Through the introduction of the $\gamma$ weight and a decoupled update rule, WSAM provides a more flexible and powerful tool for training deep neural networks, resulting in improved generalization and significant robustness to label noise.

Summary updated

BibTeX
@inproceedings{yue2023sharpness,
  author = {Yun Yue and Jiadi Jiang and Zhiling Ye and Ning Gao and Yongchao Liu and Ke Zhang},
  title = {{Sharpness-Aware Minimization Revisited: Weighted Sharpness as a Regularization Term}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2023},
}
Figure