Abstract
Sharpness-Aware Minimization (SAM) has emerged as a powerful technique for improving the generalization of deep neural networks by explicitly seeking out "flat" regions in the loss landscape. However, the computational cost of SAM—requiring an additional gradient calculation per step—remains a significant barrier. This paper introduces SAM-ON (SAM-OnlyNorm), a method that applies adversarial perturbations exclusively to the trainable affine parameters of normalization layers. Despite these parameters typically accounting for less than 0.1% of the total model weights, SAM-ON consistently matches or exceeds the performance of standard SAM. Furthermore, the study reveals a "sharpness paradox": SAM-ON often leads to sharper minima than standard training, yet achieves superior generalization, challenging the foundational assumption that flatness is the primary driver of SAM's success.
Introduction
A central goal in deep learning is to ensure that models generalize well to unseen data. The prevailing hypothesis suggests that "flat" minima—regions where the loss function changes slowly with respect to weight perturbations—correlate with better generalization. Sharpness-Aware Minimization (SAM) was developed to exploit this by adding an adversarial perturbation to weights during training, effectively smoothing the loss landscape.
While effective, SAM is computationally expensive, doubling the training time due to the required "ascent" step to find the worst-case perturbation. Previous attempts to sparsify SAM (perturbing only a subset of weights) have often resulted in significant performance degradation. This research explores whether specific components of the architecture are more critical to the SAM process than others, leading to the discovery that normalization layers are the key to SAM's efficacy.
Methodology: SAM-OnlyNorm (SAM-ON)
The authors propose SAM-ON, which restricts the SAM perturbation to the scaling ($\gamma$) and shifting ($\beta$) parameters found in normalization layers such as BatchNorm (in CNNs) or LayerNorm (in Vision Transformers).
In a standard SAM setup, all parameters $w$ are perturbed. In SAM-ON, the perturbation is calculated only for the affine parameters of the normalization layers, while the rest of the network's weights are updated using standard SGD or Adam based on the gradient at this perturbed state. To validate the unique importance of these layers, the researchers also tested a "No-Norm" control, where every parameter except those in the normalization layers was perturbed.
Experimental Results
The researchers evaluated SAM-ON across a variety of architectures (WideResNet, ResNet, ViT) and datasets (CIFAR-10/100, ImageNet, and IWSLT’14).
Generalization Performance
On CIFAR-100, SAM-ON achieved an accuracy of 84.19%, notably higher than the 83.11% achieved by standard SAM and the 80.71% of basic SGD. On ImageNet, SAM-ON remained highly competitive, even outperforming standard SAM in specific Vision Transformer (ViT-S) configurations. These results are particularly striking given that for a WideResNet-28-10, SAM-ON perturbs only approximately 0.07% of the total parameters.
Robustness and Out-of-Distribution (OOD) Performance
Beyond standard accuracy, SAM-ON demonstrated improved robustness on OOD benchmarks such as ImageNet-V2, ImageNet-R, and ImageNet-A. Despite the "sharpness" of the resulting minima (discussed below), the models trained with SAM-ON showed non-trivial adversarial robustness, often surpassing models trained with full-parameter SAM.
The Sharpness Paradox
The most significant theoretical contribution of this work is the challenge it poses to the "flatness" doctrine. Traditionally, SAM is believed to work because it reduces the sharpness of the loss landscape. However, the authors observed that SAM-ON often results in sharper minima than standard SAM, yet it achieves better generalization.
This suggests that the benefit of SAM may not be purely geometric. Instead, SAM might provide a beneficial "implicit bias" during the optimization process. Specifically, the researchers noted that SAM-ON tends to push the scaling parameter $\gamma$ toward larger values, suggesting a regularization effect on the normalization statistics rather than a simple smoothing of the entire landscape.
Potential for Efficiency
Because SAM-ON only requires gradients for the normalization layers during the ascent step, there is a theoretical potential for a 2x training speedup. By skipping the backpropagation through heavy convolutional or attention layers during the perturbation phase, computational resources can be saved. While current deep learning frameworks (like PyTorch or TensorFlow) are not yet optimized for this specific type of sparse backpropagation, the authors demonstrated wall-clock speedups in experimental settings, providing a roadmap for more efficient SAM implementations.
Conclusion
SAM-ON demonstrates that the vast majority of parameters in a neural network do not need to be perturbed to reap the benefits of Sharpness-Aware Minimization. By focusing on the tiny fraction of parameters in normalization layers, researchers can achieve state-of-the-art generalization and robustness. This discovery not only offers a path toward more efficient training but also necessitates a re-evaluation of the theoretical link between landscape flatness and generalization in deep learning.
Summary updated