Minimum sharpness: Scale-invariant parameter-robustness of neural networks

Hikaru Ibayashi, Takuo Hamaguchi, Masaaki ImaizumiarXiv 2021

Abstract

Traditional measures of neural network "sharpness," such as the trace of the Hessian matrix, are often used to predict generalization performance. However, these metrics suffer from a critical flaw: they are sensitive to weight scaling transformations that do not alter the network's output. This paper introduces Minimum Sharpness (MS), a scale-invariant metric that addresses this limitation. By defining sharpness as the minimum trace across all scale-equivalent network configurations, the authors provide a mathematically rigorous and computationally efficient tool. Empirical results demonstrate that MS correlates strongly with the generalization gap and can be computed orders of magnitude faster than traditional baselines.

Introduction

A central goal in deep learning is understanding why certain models generalize well to unseen data while others do not. A prominent hypothesis suggests that "flat minima"—regions in the parameter space where the loss function is relatively insensitive to perturbations—are indicative of superior generalization. Conversely, "sharp minima" are thought to lead to poor performance on test data.

Despite its intuitive appeal, the concept of sharpness is plagued by scale-sensitivity. In networks using rectified linear units (ReLU), weight scaling (e.g., multiplying one layer's weights by a constant and dividing the next by the same constant) leaves the model's function unchanged but can dramatically alter traditional sharpness metrics. This "scale-sensitivity bug" means that a model's perceived sharpness is often an artifact of its parameterization rather than its intrinsic properties.

The Scale-Sensitivity Problem

Consider a standard feedforward neural network. Due to the homogeneity of the ReLU activation, there exists a continuous set of weight configurations that represent the exact same mathematical function. Traditional metrics like the trace of the Hessian, $Tr[H]$, are not invariant under these transformations. Consequently, a model could be deemed "sharp" or "flat" simply by rescaling its weights, rendering the metric unreliable for comparing different models or training runs.

Previous attempts to resolve this have often relied on computationally expensive approximations or heuristics that lack formal theoretical grounding.

Proposed Method: Minimum Sharpness

The authors propose Minimum Sharpness (MS) as a robust, scale-invariant alternative. MS is defined as the minimum possible value of the Hessian trace over the set of all scale-equivalent networks: $$MS_\theta = \min_{\theta' \sim \theta} Tr[H(\theta')]$$ where $\theta' \sim \theta$ denotes all parameterizations that produce the same output as $\theta$.

Tractable Computation

A key contribution of this work is making the calculation of MS computationally feasible. Calculating the full Hessian for modern networks is typically intractable. The authors provide a decomposition (Proposition 1) that allows the trace to be computed using only the gradients of the model's logits. This reduces the computational overhead to a small number of forward and backward passes.

Validation of the proposed tractable Hessian trace calculation against the baseline.

As shown in Figure 1, the proposed method yields values that perfectly align with the baseline Hessian trace calculation across various architectures (FCNNs and CNNs) and dataset sizes ($n$), confirming its mathematical exactness while being significantly faster.

The Geometric Mean Solution

For networks without bias terms, the authors derive a closed-form solution (Theorem 1). They prove that Minimum Sharpness is proportional to the geometric mean of the layer-wise Hessian traces. This result implies that optimal (minimum) sharpness is achieved when sensitivity is balanced across all layers of the network.

Experimental Results

The effectiveness of Minimum Sharpness was evaluated using MNIST and corrupted versions of the dataset where labels were shuffled to varying degrees. Shuffling labels creates a controlled "generalization gap," allowing researchers to test if a metric can track the loss of generalization.

Correlation with Generalization

The experiments revealed a strong positive correlation between Minimum Sharpness and the generalization gap. As the ratio of shuffled labels increased, the model's ability to generalize decreased, and the MS value rose accordingly.

Correlation between generalization gap and sharpness metrics (Minimum Sharpness vs. Normalized Sharpness) across varying shuffled-label ratios.

Figure 3 demonstrates that both Minimum Sharpness and a related "Normalized Sharpness" metric effectively track the generalization gap. However, the proposed MS method offers a more direct theoretical link to the geometry of the loss landscape.

Efficiency and Stability

In terms of performance, the proposed method achieved a 500x to 600x speedup over baseline Hessian calculations. For a small fully connected network, the computation time dropped from approximately 11 seconds to just 0.02 seconds. Furthermore, the method demonstrated high numerical stability across different architectures, including CNNs like LeNet.

Conclusion and Future Work

Minimum Sharpness provides a theoretically sound and practically efficient solution to the scale-sensitivity problem in deep learning. By ensuring invariance to weight scaling, it offers a more reliable measure of a model's intrinsic robustness and generalization potential.

While the current work focuses on the trace of the Hessian and specific architectures like no-bias FCNNs, future research could extend these principles to other metrics (such as the maximum eigenvalue) and more complex architectures like Transformers. Testing these metrics on large-scale industrial models remains a critical next step for widespread adoption.

Summary updated

BibTeX
@misc{ibayashi2021minimum,
  author = {Hikaru Ibayashi and Takuo Hamaguchi and Masaaki Imaizumi},
  title = {{Minimum sharpness: Scale-invariant parameter-robustness of neural networks}},
  year = {2021},
  eprint = {2106.12612},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2106.12612},
}
Figure