Gradient Norm Aware Minimization Seeks First-Order Flatness and Improves Generalization

Xingxuan Zhang, Renzhe Xu, Han Yu, Hao Zou, Peng Cui

TL;DR

This paper introduces Gradient norm Aware Minimization (GAM), a novel optimization technique that seeks "first-order flatness" to improve neural network generalization. By penalizing the maximum gradient norm within a neighborhood rather than just the maximum loss value (as in SAM), GAM finds flatter minima with lower Hessian spectra and consistently outperforms standard optimizers across various vision tasks.

What Problem Does This Paper Address?

Deep learning models are notoriously over-parameterized, often leading them to converge to "sharp" minima that overfit training data and generalize poorly to new samples. Recent state-of-the-art methods like Sharpness-Aware Minimization (SAM) tackle this by seeking "flat" minima—regions where the loss doesn't change much if you slightly perturb the weights.

However, the authors argue that SAM’s definition of flatness, which they call zeroth-order flatness (ZOF), is insufficient. ZOF only looks at the worst-case loss value within a radius $\rho$. As illustrated in Figure 1, ZOF can be "blind" to high-frequency fluctuations (multiple sharp peaks and valleys) within that radius, or it can be misled when the maximum loss value doesn't align with the actual trend of the loss landscape.

ZOF vs FOF comparison

Methods

The authors propose first-order flatness (FOF), which focuses on the maximal gradient norm within a perturbation radius. Intuitively, if the gradient stays small everywhere in a neighborhood, the loss surface must be truly flat.

Key technical components include:

  • The GAM Objective: A new regularizer that minimizes the empirical loss plus a term representing the maximum gradient norm in a local ball $B(\theta, \rho)$.
  • Hessian-Vector Products: To avoid the massive computational cost of calculating a full Hessian matrix, GAM approximates the gradient of the first-order flatness using Hessian-vector products, making it efficient enough for deep models.
  • Accelerated GAM: A variant that uses first-order Taylor expansions to further speed up the process, requiring only a fraction of the iterations to use the full GAM penalty to achieve significant generalization gains.

Datasets

The researchers evaluated GAM across a wide spectrum of benchmarks and architectures:

  • Image Classification: CIFAR-10, CIFAR-100, and the large-scale ImageNet dataset.
  • Transfer Learning: Stanford Cars, Oxford_IIIT_Pets, and Food101.
  • Architectures: ResNets (18, 50, 101), WideResNet, ResNeXt, PyramidNet, and Vision Transformers (ViT-S/B, Swin-T).

Key Insights and Ideas

  • FOF is a "Stronger" Measure: The authors prove that first-order flatness actually bounds zeroth-order flatness. If you control the gradient norm, you inherently control the loss fluctuations.
  • Direct Curvature Control: They demonstrate a mathematical link showing that FOF directly controls the maximum eigenvalue of the Hessian ($\lambda_{max}$) at local minima. Since $\lambda_{max}$ is a standard measure of curvature, GAM is effectively a direct way to minimize curvature.
  • Multiple Minima are Common: Through empirical testing, they found that having multiple local minima within a standard perturbation radius ($\rho=0.1$) is actually very common in practice (see Figure 2). This justifies why a gradient-based measure (FOF) is needed to distinguish between "bumpy" regions and truly smooth valleys.
Figure 2. The distribution of numbers of local minima and maxima within the perturbation radius ρ after convergence.

Key Results

GAM consistently improves performance over standard SGD and AdamW optimizers, and even enhances SAM when the two are combined:

  • Generalization Boost: On CIFAR-100 with ResNet-18, SGD+GAM reached 79.53% accuracy compared to 78.32% for vanilla SGD. When combined with SAM, it reached 80.45%.
  • Flatter Landscapes: Hessian analysis (Figure 3) shows that GAM significantly reduces both the Hessian trace and $\lambda_{max}$ compared to SGD and SAM, leading to visibly smoother loss landscapes (Figure 5).
  • Efficiency: The authors show that applying GAM to only 1/10th of the training iterations provides nearly the same benefit as applying it to all iterations, keeping the extra computational overhead below 25%.

Hessian spectra comparison Loss landscape visualization

Limitations and Future Work

While empirically successful, the authors note a few areas for further exploration:

  • Theoretical Depth: A more rigorous theoretical explanation is needed to determine exactly why a stronger flatness measure is always better for generalization in different contexts.
  • ZOF + FOF Synergy: While the combination of SAM (zeroth-order) and GAM (first-order) works best in practice, the theoretical contribution of each when combined requires more thorough analysis.
  • Hyperparameters: Like SAM, GAM introduces new hyperparameters ($\rho$ and $\alpha$) that require tuning for optimal performance.

Summary updated

BibTeX
@misc{zhang2023gradient,
  author = {Xingxuan Zhang and Renzhe Xu and Han Yu and Hao Zou and Peng Cui},
  title = {{Gradient Norm Aware Minimization Seeks First-Order Flatness and Improves Generalization}},
  year = {2023},
  eprint = {2303.03108},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.03108},
}
Figure