Noise Stability Optimization for Finding Flat Minima: A Hessian-based Regularization Approach

Hongyang R. Zhang, Dongyue Li, Haotian Ju

Abstract

The training of over-parameterized neural networks has received much study in recent literature. An important consideration is the regularization of over-parameterized networks due to their highly nonconvex and nonlinear geometry. In this paper, we study noise injection algorithms, which can regularize the Hessian of the loss, leading to regions with flat loss surfaces. Specifically, by injecting isotropic Gaussian noise into the weight matrices of a neural network, we can obtain an approximately unbiased estimate of the trace of the Hessian. However, naively implementing the noise injection via adding noise to the weight matrices before backpropagation presents limited empirical improvements. To address this limitation, we design a two-point estimate of the Hessian penalty, which injects noise into the weight matrices along both positive and negative directions of the random noise. In particular, this two-point estimate eliminates the variance of the first-order Taylor's expansion term on the Hessian. We show a PAC-Bayes generalization bound that depends on the trace of the Hessian (and the radius of the weight space), which can be measured from data. We conduct a detailed experimental study to validate our approach and show that it can effectively regularize the Hessian and improve generalization.

Introduction

In deep learning, "flat minima"—regions of the loss landscape where the loss remains relatively constant under small weight perturbations—are known to generalize better than "sharp minima." While noise injection (adding random noise to weights during training) is a classic approach to finding these regions, simple implementations often fail to yield significant performance gains.

The primary obstacle is variance. When noise is added to weights, the resulting gradient estimate is dominated by first-order noise, which obscures the second-order signal necessary to regularize "flatness" (the Hessian). While methods like Sharpness-Aware Minimization (SAM) target the largest eigenvalue of the Hessian, we argue that explicitly regularizing the Hessian trace (average curvature) provides a more robust and effective path to generalization.

Methods: Noise Stability Optimization (NSO)

We propose Noise Stability Optimization (NSO), an algorithm designed to explicitly regularize the Hessian trace while minimizing gradient variance.

Two-Point Noise Injection

The core innovation of NSO is a two-point estimate. Instead of calculating the gradient at a single noisy point $W + U$, NSO computes gradients at both $W + U$ and $W - U$.

Illustration of the NSO two-point noise injection scheme.

By averaging these gradients, the first-order Taylor expansion terms cancel out. This allows the optimizer to isolate the second-order Hessian term, significantly reducing variance and allowing the training process to effectively "see" and minimize the curvature of the loss surface. NSO requires two gradient computations per step, making it a drop-in replacement for practitioners already using sharpness-aware methods like SAM.

Theoretical Foundation

NSO implicitly penalizes the trace of the Hessian matrix. We derive a new PAC-Bayes generalization bound that depends directly on the Hessian trace and the radius of the weight space. Unlike many theoretical bounds, this one is "non-vacuous," matching the scale of errors observed in real-world experiments.

Experimental Results

We validated NSO across image classification (ResNets), multimodal learning (CLIP), and LLM reasoning (GPT-2).

Performance and Curvature Reduction

NSO consistently outperformed standard SGD and SAM variants. For ResNet fine-tuning, it delivered up to a 2.4% increase in test accuracy. Crucially, NSO reduced the Hessian trace by 15.8% and the largest eigenvalue by 9.7% on average. This suggests that trace regularization is a powerful proxy for reducing overall sharpness.

Empirical validation of the relationship between the generalization gap and the Hessian trace across different architectures.

As shown in the figure above, the empirical generalization gap closely tracks the theoretical bound related to the Hessian trace across MLP, BERT, and GNN architectures, validating our theoretical framework.

Broad Applicability

  • Multimodal: In CLIP pretraining, NSO achieved 1.4% higher recall in image retrieval tasks.
  • NLP: In LLM fine-tuning for reasoning tasks (CommonsenseQA and StrategyQA), NSO yielded 25% lower trace values and a 5.3% improvement in test accuracy.
  • Synergy: The method is orthogonal to other techniques; combining NSO with data augmentation and weight decay led to even stronger regularization and better performance.

Conclusion and Limitations

NSO provides a computationally efficient method for finding flat minima via Hessian trace regularization. While it shows strong empirical gains, it shares the 2x computational overhead of SAM. Future work will explore combining NSO with accelerated gradient methods and further optimizing it for the specific geometries of Transformer-based architectures.

Summary updated

BibTeX
@article{zhang2024noise,
  author = {Hongyang R. Zhang and Dongyue Li and Haotian Ju},
  title = {{Noise Stability Optimization for Finding Flat Minima: A Hessian-based Regularization Approach}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=yfrNkb2Ldd},
}
Figure