# Normalization Layers Are All That Sharpness-Aware Minimization Needs

Perturbing only normalization layers improves SAM's generalization

Maximilian Mueller, Tiffany Vlaar, David Rolnick, Matthias Hein · arXiv · 2023-6-7

- **Problem** SAM needs an extra gradient pass each step, and its gains are often credited to lower sharpness. Sparse SAM variants cut cost but did not reduce wall-clock time, so it was unclear whether sparsity or parameter choice mattered.
- **Method** SAM-ON applies SAM's ascent step only to the affine scale and shift parameters of normalization layers. Unlike SAM-all, the other weights are left unperturbed, while the update is still applied to all weights.
- **Results** On WRN-28 with CIFAR-100, SAM-ON reached 84.19 test accuracy, compared to 83.11 for SAM-all. A random mask at 99.95% sparsity reached 80.97, so sparsity alone does not explain the gain.

![Figure 1: The interplay of normalization layers with SAM: Perturbing only normalization layers (OnlyNorm, dashed) improves generalization performance, while om…](https://refivu.com/papers/27a5428d-a37a-4372-9580-46a7c2bebed4/figures/figure-f6487a264227f97a588bfee607448a33.png?thumb=512)

**Figure 1** : The interplay of normalization layers with SAM: Perturbing only normalization layers (OnlyNorm, dashed) improves generalization performance, while omitting them in the perturbation (no-norm, dotted) can harm training. WideResNet-28-10 trained with different SAM-variants on CIFAR-100. Best seen in color.

[Original paper](https://arxiv.org/abs/2306.04226v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Maximilian Mueller, Tiffany Vlaar, David Rolnick, Matthias Hein · Normalization Layers Are All That Sharpness-Aware Minimization Needs · Original paper figure · Extracted the figure area from page 2 of the original PDF.

## Why SAM's gains are hard to pin down

SAM seeks minima where the loss stays low within a small neighborhood of the weights. Each step needs an additional forward-backward pass at the perturbed point, compared to SGD.

Sparse variants try to cut this cost by perturbing only part of the parameters. Mi et al. found that perturbing 50% of the parameters could match or beat full SAM. Their method did not cut wall-clock time, even though it aimed at making SAM more efficient. That raises a fair question: does the gain come from sparsity, or from which parameters are perturbed?

Normalization layers are thought to reduce sharpness too, similar to the effect of SAM. Their affine parameters can carry much of the layer's expressive power. That makes the normalization parameters a natural place to test the sparsity question.

The ASAM elementwise-ℓ2 variant may already perturb normalization layers implicitly. The authors hypothesize this, which would explain why excluding them (no-norm) strongly reduces its performance.

## Perturbing only the normalization parameters

SAM-ON keeps SAM's two-step update and narrows the ascent step to the affine parameters of normalization layers. The authors call this SAM-ON, short for SAM-OnlyNorm, and compare it with SAM-all, which perturbs every parameter. The reverse, no-norm, leaves the affine normalization parameters out of the adversarial SAM-step and perturbs everything else.

Standard SAM approximates the worst case inside an ℓ2 ball with a single gradient step. That step is ϵ = ρ∇L(w)/‖∇L(w)‖2, where ρ sets the radius of the perturbation. SAM-ON restricts this perturbation to the trainable scale γ and shift β of the normalization layers, so the other weights are not perturbed. The gradient is then taken at the perturbed weights and applied to all weights with learning rate α.

BatchNorm computes its mean and variance over the batch dimension, while LayerNorm computes them over the embedding dimension. The two architectures therefore offer different places to apply the perturbation, which is why the paper tests both ResNets and Vision Transformers.

The SAM variants differ in the perturbation norm, either ℓ2 or ℓ∞, and in the normalization operator. ASAM's elementwise normalization scales each weight by its magnitude plus a small constant, with η typically set to 0.01. Layerwise normalization instead uses the ℓ2 norm of each layer, which the authors apply in their experiments. Under this design, perturbing only the normalization parameters with ρ-tuned variants is the change that the rest of the section evaluates.

## CIFAR results for ResNets

The first test uses WRN-28 on CIFAR-100, trained with several SAM variants. For the basic-augmentation SAM variant with p=2, SAM-ON scored 84.19 test accuracy compared to 83.11 for SAM-all. The authors report SAM-ON ahead of SAM-all for every SAM variant they considered.

No-norm drops accuracy for elementwise-ℓ2 variants, but for other variants it stays close to SAM-all. The authors hypothesize that elementwise-ℓ2 already perturbs normalization layers heavily, so removing them hurts it.

Table 1 covers ResNet-56, RNxT and WRN-28 on CIFAR-100, with mean and standard deviation over 3 seeds. On average SAM-ON beats SAM-all for all considered SAM variants, and layerwise-ℓ2 is best in most settings.

The authors also varied batch size and m for WRN-28, and SAM-ON beat SAM-all in every combination. They read this as showing that Ghost BatchNorm does not drive the gain.

## ViT and ImageNet results

ViT-S trained from scratch on CIFAR-100 with AdamW shows the same pattern as the ResNets. With basic augmentation plus AA, SAM-ON reaches 69.13 test accuracy, compared to 66.58 for SAM-all. For the elementwise-ℓ2 variants, disabling the normalization parameters in the adversarial step causes a strong accuracy drop.

![Figure 2: The interplay of normalization layers with SAM for ViT training : ViT-S trained with different SAM-variants on CIFAR-100. Like for ResNets, perturbin…](https://refivu.com/papers/27a5428d-a37a-4372-9580-46a7c2bebed4/figures/figure-dc36cab8a1203fad84fb2bba415b152c.png?thumb=512)

**Figure 2** : The interplay of normalization layers with SAM for ViT training : ViT-S trained with different SAM-variants on CIFAR-100. Like for ResNets, perturbing only normalization layers (OnlyNorm) improves generalization performance, while omitting them in the perturbation (no-norm) can harm training.

[Original paper](https://arxiv.org/abs/2306.04226v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

On ImageNet, the authors trained a ResNet-50 for 100 epochs on eight 2080-Ti GPUs with m = 64. That setup gives an overall batch size of 512. Layerwise ℓ2 is the one variant where SAM-all wins, at 78.14 compared to 77.87 for SAM-ON. For elementwise ℓ2, SAM-ON reaches 77.82 against 77.65 for SAM-all. Elementwise ℓ∞ shows a larger gap, with SAM-ON at 77.82 and SAM-all at 77.45.

So the ImageNet picture depends on the variant, and SAM-ON doesn't win everywhere.

They tested AdamW and Lion as base optimizers and evaluated both ID and OOD datasets. With Lion, SAM-ON reaches 72.64 ID accuracy, compared to 71.90 for SAM-all and 68.20 for the vanilla optimizer.

Since Wei et al. showed that SAM-trained models resist small adversarial perturbations, the authors also tested SAM-ON's robustness. For AdamW, SAM-ON either outperforms SAM-all on adversarial robustness or matches it within standard deviations.

## Is sparsity the explanation?

The sparsified SAM approach of Mi et al. picks the parameters to perturb with a binary mask. The authors call the Fisher-based variant SSAM-F and focus on it, rather than on the dynamic variant SSAM-D. Mi et al. don't clearly favour either method, so the authors report SSAM-D results in Appendix B.2. According to Mi et al., neither sparse approach improves wall-clock time, whereas SAM-ON does.

![Table 5: SAM-ON outperforms other sparse perturbation approaches: Although SSAM-F \[42\] with different sparsity levels can outperformSAM-all on CIFAR-100 with W…](https://refivu.com/papers/27a5428d-a37a-4372-9580-46a7c2bebed4/figures/figure-3fb7f0b7feb7adbdbe5cef131bb6ddf7.png?thumb=512)

**Table 5** : SAM-ON outperforms other sparse perturbation approaches: Although SSAM-F \[42\] with different sparsity levels can outperformSAM-all on CIFAR-100 with WRN-28, it is less effective than SAM-ON, especially when probed at very high sparsity levels.

[Original paper](https://arxiv.org/abs/2306.04226v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

The authors compare SAM-ON, SSAM-F and a random mask at the same sparsity on ResNet-18 with CIFAR-10 in Figure 4 (left). For WRN-28 on CIFAR-100, they run the comparison in Table 5, with SAM-ON at 99.95% sparsity. A random mask at 99.95% sparsity reaches 80.97±0.2 test accuracy, compared to 84.19±0.2 for SAM-ON. SAM-all reaches 83.11±0.3 at 0% sparsity, so the random mask falls well below the dense baseline.

SSAM-F reaches 83.94±0.1 at 50% sparsity and 83.14±0.1 at 99.95% sparsity.

Even so, SSAM-F is less successful than SAM-ON, particularly at the very high sparsity that SAM-ON uses. A random mask performs poorly at SAM-ON's sparsity levels, which lie above 99.9% in both settings. These results suggest that sparsity alone doesn't account for SAM-ON's gains.

## Sharpness and feature rank of SAM-ON

The authors measure sharpness with logit-normalized worst-case adaptive ℓ∞ m-sharpness, the definition that correlated best with generalization error on CIFAR data. They run 20 steps of AutoPGD, a hyperparameter-free method built for estimating adversarial robustness. Here AutoPGD works in the weight space rather than the input space it was designed for.

Alongside it they report a 1-step sharpness, the loss change from a single gradient step like the SAM perturbation. For 1-step sharpness they pick a larger ρ than for 20 steps, so that the loss changes end up similar.

On WRN-28 with CIFAR-100, SAM-ON reaches the best generalization among SGD, SAM and ASAM-ℓ∞ variants. At ρ = 0.007 with 20 steps, SAM-ON has a sharpness of 0.585±0.018. SAM-all reaches only 0.309±0.011 under the same setting. SAM-ON's test accuracy is 84.19±0.2, compared to 83.11±0.3 for SAM-all. The authors read this as support for Andriushchenko and Flammarion, who doubt that flatter minima are the sole reason for SAM's gains.

SAM-ON is sharper than SAM-all for most of the extra metrics in Appendix B.10, though there are exceptions.

Andriushchenko et al. showed that SAM-all leads to features of lower rank than vanilla optimizers. For WRN-28, the feature rank is 4004±12 with SGD, 3798±17 with SAM-all and 3728±11 with SAM-ON. SAM-ON lowers the rank compared to SGD, but it shows no significant change compared to SAM-all.

## Where the computational savings of SAM-ON come from

The ascent step of SAM-ON still needs gradients at the early layers, because their normalization parameters are trainable. Figure 3 plots test accuracy against normalized wall-clock runtime for a WRN-28 and a ResNeXt on CIFAR-100, trained with batch size 128 on a single A100 with PyTorch.

![Figure 3: Computational gains of SAM-ON over SAM-all:Test accuracy vs. normalized wall-clock runtime for SAM and different variations of SAM-ON for a WRN-28 (l…](https://refivu.com/papers/27a5428d-a37a-4372-9580-46a7c2bebed4/figures/figure-6217153524b22c3de1784f9dda0d9d26.png?thumb=512)

**Figure 3** : Computational gains of SAM-ON over SAM-all:Test accuracy vs. normalized wall-clock runtime for SAM and different variations of SAM-ON for a WRN-28 (left) and a ResNeXt (right) on CIFAR-100. Only perturbing selected normalization parameters (e.g. those from block 3, or those from block 2 and 3) can lead to further computational gains. Reported values are averaged over three random seeds.

[Original paper](https://arxiv.org/abs/2306.04226v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

That gain comes with only a small loss in test accuracy. Perturbing the normalization layers of Block 2 and 3 (B2+B3) slightly improves test accuracy over SAM-ON for both models, while the runtime stays significantly lower. The authors didn't investigate this B2+B3 variant thoroughly, for example with other ASAM perturbation models or more network architectures.

Mi et al. report that their sparse perturbation approach doesn't reduce wall-clock time at present. Their mask selection adds computational cost on top of that, so SAM-ON beats it in both cost and generalization. The authors note that future hardware for sparse operation may allow acceleration of such approaches.

## What changes in the affine parameters under SAM-ON

Under SAM-ON, the scaling parameter γ moves, while the shift parameter β barely changes. The authors compared the distributions of γ and β for a WRN-28 trained with SAM-ON and with SAM-all. Their plots show only minor changes in β, but a clear shift of γ towards larger values for SAM-ON. The authors trained more SAM variants and found the same pattern in their Figure 9 in Appendix B.6.

The γ shift appears only for variants whose optimal ρ moves towards larger values under SAM-ON compared to SAM-all.

![Figure 5: SAM-ON changes the weight distribution of the normalization layer weights of a WRN-28 towards larger values. More SAM-variants are shown in Figure 9…](https://refivu.com/papers/27a5428d-a37a-4372-9580-46a7c2bebed4/figures/figure-0531a1d4bd1532e31a129037e1b0b8ae.png?thumb=512)

**Figure 5** : SAM-ON changes the weight distribution of the normalization layer weights of a WRN-28 towards larger values. More SAM-variants are shown in Figure 9 in the appendix.

[Original paper](https://arxiv.org/abs/2306.04226v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

The shift is absent for ASAM elementwise-ℓ2, the variant where excluding normalization layers hurts most. The authors hypothesize that this perturbation model already focuses mostly on the normalization layers. Under that hypothesis, excluding the normalization layers with no-norm causes a drastic performance drop, and SAM-ON changes γ only minimally.

For the other variants, the authors suggest SAM-all doesn't perturb the normalization layers enough to be effective. That explains why no-norm has little effect for them, while SAM-ON produces a distinctive shift of the γ distribution.

## Where the evidence stops

The authors focus on vision data, following the main inspirations for this work. Their ResNet experiments cover CIFAR and ImageNet, and their Vision Transformer runs cover CIFAR and ImageNet as well. They didn't test text tasks, so the reported gains stay confined to image benchmarks. The sparsity comparison uses one ResNet-18 setting and one WRN-28 setting.

The B2+B3 variant wasn't studied thoroughly with other ASAM perturbation models or more network architectures. Its test accuracy slightly improved over SAM-ON for both models, but the authors left this variant as future work. The timing results come from a WRN-28 and a ResNeXt on CIFAR-100 only. Those runs used batch size 128 on a single A100 with PyTorch.

The reported runtime values are averaged over three random seeds.

The sharpness comparison covers one setting: a WRN-28 on CIFAR-100. Each method's sharpness values are averaged over three models. Worst-case sharpness is measured with 20 steps of AutoPGD, alongside 1-step sharpness. Under ASAM elementwise ℓ∞, SAM-ON reached 84.14±0.2 test accuracy versus 83.25±0.2 for SAM-all.

The random-mask baseline was tested at 99.95% sparsity on WRN-28. On the ResNet-18 setting, the random mask matched SAM-ON's sparsity of 99.93%. The authors left SSAM-D out of the main text and placed its results in Appendix B.2.

## Paper info

- **Authors**: Maximilian Mueller, Tiffany Vlaar, David Rolnick, Matthias Hein
- **Venue**: arXiv · Preprint
- **First published**: 2023-6-7
- **Added**: 2026-11-5
- **Updated**: 2023-11-17
- **Version**: v2
- **arXiv**: 2306.04226
- **Category**: cs.LG · cs.CV
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2306.04226v2) · [PDF ↗](https://arxiv.org/pdf/2306.04226v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Sharpness-aware minimization (SAM) was proposed to reduce sharpness of minima and has been shown to enhance generalization performance in various settings. In this work we show that perturbing only the affine normalization parameters (typically comprising 0.1% of the total parameters) in the adversarial step of SAM can outperform perturbing all of the parameters.This finding generalizes to different SAM variants and both ResNet (Batch Normalization) and Vision Transformer (Layer Normalization) architectures. We consider alternative sparse perturbation approaches and find that these do not achieve similar performance enhancement at such extreme sparsity levels, showing that this behaviour is unique to the normalization layers. Although our findings reaffirm the effectiveness of SAM in improving generalization performance, they cast doubt on whether this is solely caused by reduced sharpness.

## Quote from the paper

Maximilian Mueller, Tiffany Vlaar, David Rolnick, Matthias Hein (2023). Normalization Layers Are All That Sharpness-Aware Minimization Needs. arXiv:2306.04226v2. https://arxiv.org/abs/2306.04226v2

**BibTeX**

```
@misc{mueller2023normalization,
  title = {{Normalization Layers Are All That Sharpness-Aware Minimization Needs}},
  author = {Maximilian Mueller and Tiffany Vlaar and David Rolnick and Matthias Hein},
  year = {2023},
  eprint = {2306.04226},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.04226v2}
}
```

## Other paper commentary

- [mixup: Beyond Empirical Risk Minimization](https://refivu.com/en/papers/cc1e3261-af7e-47fa-99d8-0806fbe6afcf-mixup-beyond-empirical-risk-minimization.md)
- [Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks](https://refivu.com/en/papers/c1050ccf-ffa6-4158-8fff-24b3a8223df6-weight-normalization-a-simple-reparameterization-to.md)
- [Neural Tangent Kernel: Convergence and Generalization in Neural Networks](https://refivu.com/en/papers/00c81960-6246-4381-80a5-696fbeb26240-neural-tangent-kernel-convergence-and-generalization-in.md)
- [The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks](https://refivu.com/en/papers/9c072b5c-bd96-4202-8960-653ce6a7f2fb-the-lottery-ticket-hypothesis-finding-sparse-trainable.md)
- [Adam: A Method for Stochastic Optimization](https://refivu.com/en/papers/1e4ce3cf-c297-4440-9078-a86a09a9caca-adam-a-method-for-stochastic-optimization.md)
- [Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift](https://refivu.com/en/papers/bd3e1105-da91-407a-8b28-4217cd2afedf-batch-normalization-accelerating-deep-network-training-by.md)
- [GIFT-Eval: A Benchmark For General Time Series Forecasting Model Evaluation](https://refivu.com/en/papers/9c25df27-c1ce-48fc-bead-91671684c182-gift-eval-a-benchmark-for-general-time-series.md)
- [Self-supervised Learning for Video Correspondence Flow](https://refivu.com/en/papers/d2ae4b57-a428-492b-868a-3490e48aa23c-self-supervised-learning-for-video-correspondence-flow.md)
- [Instruction-driven history-aware policies for robotic manipulations](https://refivu.com/en/papers/f165e0f3-57f4-459b-aadd-c12aee638ce4-instruction-driven-history-aware-policies-for-robotic.md)
- [Perceiver-Actor: A Multi-Task Transformer for Robotic Manipulation](https://refivu.com/en/papers/36489f39-2d0a-49d5-8c29-68447645c8d7-perceiver-actor-a-multi-task-transformer-for-robotic.md)
- [Equivariant Descriptor Fields: SE(3)-Equivariant Energy-Based Models for End-to-End Visual Robotic Manipulation Learning](https://refivu.com/en/papers/46f6ef1f-5422-4a62-939d-fb8970138aff-equivariant-descriptor-fields-se-3-equivariant-energy-based.md)
- [RoboCat: A Self-Improving Generalist Agent for Robotic Manipulation](https://refivu.com/en/papers/b6495492-d71b-4904-97d1-2d044bfa800b-robocat-a-self-improving-generalist-agent-for-robotic.md)

## Terms in this paper

- [CIFAR-10](https://refivu.com/en/terms/19035a518d0a-cifar-10)
- [Batch Normalization](https://refivu.com/en/terms/2b3e5f8509f6-batch-normalization)
- [layer normalization](https://refivu.com/en/terms/7af9eccdb60d-layer-normalization)
- [CIFAR-100](https://refivu.com/en/terms/5afa3b877d18-cifar-100)
- [test accuracy](https://refivu.com/en/terms/021c3c30b755-test-accuracy)
- [SAM](https://refivu.com/en/terms/702df428b8a1-sam)
- [LayerNorm](https://refivu.com/en/terms/71749b6cdbf4-layernorm)
- [BatchNorm](https://refivu.com/en/terms/c1d81c43c87f-batchnorm)
- [generalization performance](https://refivu.com/en/terms/b03973a49a77-generalization-performance)
- [sharpness](https://refivu.com/en/terms/5eab0d046f0d-sharpness)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/27a5428d-a37a-4372-9580-46a7c2bebed4-normalization-layers-are-all-that-sharpness-aware)
