Layer-Wise Adaptive Gradient Norm Penalizing Method for Efficient and Accurate Deep Learning

Sunwoo Lee

Abstract

Sharpness-Aware Minimization (SAM) significantly improves model generalization by seeking flatter minima in the loss landscape. However, its requirement for double-gradient calculations makes it computationally expensive. This paper proposes Layer-wise SAM, an adaptive method that perturbs only a small subset of critical layers with the highest gradient norms. This approach achieves state-of-the-art accuracy while maintaining a fraction of SAM's computational overhead, making sharpness-aware training practical for large-scale applications.

Introduction

Generalization remains a central challenge in deep learning. Models that converge to "flat" minima—regions where small parameter perturbations do not significantly increase loss—tend to generalize better than those in "sharp" regions. Sharpness-Aware Minimization (SAM) was introduced to explicitly target these flat regions. Despite its success, SAM's primary drawback is efficiency: it requires two backward passes per update, effectively doubling training time.

Methodology: Layer-Wise Perturbation

The proposed Layer-wise SAM is based on the observation that not all layers contribute equally to a model's overall sharpness. Instead of perturbing the entire parameter space, the algorithm identifies and targets only the most "critical" layers.

The Algorithm

  1. Monitoring: The gradient norm of each layer is tracked during the training process.
  2. Selection: A subset of $k$ layers with the largest gradient norms is selected.
  3. Targeted Perturbation: Gradient ascent perturbation is applied exclusively to these $k$ layers.
  4. Global Update: A standard gradient descent update is performed for the entire model.
Gradient L-2 Norms across layers for CIFAR-10 and Oxford_Flowers102 datasets.

This adaptive selection allows the model to focus its computational budget on the layers that most influence the loss landscape's sharpness at any given point in training.

Theoretical Convergence

The paper provides a convergence analysis demonstrating that the $O(1/\sqrt{T})$ convergence rate is maintained regardless of the number of layers selected ($k$). This theoretical guarantee allows practitioners to choose a very small $k$ to maximize training speed without risking divergence.

Key Insights

Global Suppression through Local Targeting

A significant finding is that penalizing the gradient norm of just a few critical layers effectively suppresses the gradient norm of the entire model. This suggests that the sharpness of the global landscape is heavily influenced by a small number of sensitive layers.

Output-Side Sensitivity

Empirical analysis indicates that layers closer to the output often exhibit larger gradient norms and sharper loss landscapes. Consequently, focusing on these layers yields the most significant improvements in generalization for the least computational cost.

Visualizing the Landscape

The impact of Layer-wise SAM is visible in the 3D loss landscapes of individual layers. Targeted layers exhibit significantly flatter profiles compared to standard SGD training.

3D visualization of the training loss landscape for Layer 12.

Experimental Results

The method was evaluated on CIFAR-10, CIFAR-100, and Oxford_Flowers102 using architectures like ResNet-20 and Wide-ResNet.

  • Accuracy: Layer-wise SAM consistently matches or exceeds standard SAM performance. On CIFAR-100, it achieved 81.25% accuracy, surpassing Generalized SAM (80.83%) and vanilla SGD (79.41%).
  • Efficiency: The throughput gains are substantial. For ResNet-20, Layer-wise SAM was only 8.5% slower than vanilla SGD, a significant improvement over the 30-50% overhead typically associated with standard SAM.
  • Versatility: The method proved effective for both training from scratch and fine-tuning Vision Transformers (ViT-b16).

Conclusion and Future Work

Layer-wise SAM offers a practical path toward efficient sharpness-aware training. By adaptively targeting critical layers, it bridges the gap between the high generalization of SAM and the efficiency of SGD. Future work will explore the "post-decay" behavior where gradient norms increase after learning rate reduction and further optimize layer selection for various network architectures.

Summary updated

BibTeX
@inproceedings{lee2024layer,
  author = {Sunwoo Lee},
  title = {{Layer-Wise Adaptive Gradient Norm Penalizing Method for Efficient and Accurate Deep Learning}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
  doi = {10.1145/3637528.3671728},
}
Figure