A Reparameterization-Invariant Flatness Measure for Deep Neural Networks

Henning Petzka, Linara Adilova, Michael Kamp, Cristian SminchisescuarXiv 2019

Abstract

Standard measures of flatness in neural networks, such as the spectral norm or trace of the Hessian, are sensitive to weight reparameterization, making them unreliable indicators of generalization. We present a novel flatness measure that incorporates the squared norm of the weights, achieving layer-wise reparameterization invariance. Empirical results on CIFAR-10 and MNIST demonstrate that this invariant measure, particularly when based on the Hessian trace, correlates strongly with generalization performance across various training regimes.

Introduction

The relationship between the geometry of the loss landscape and the generalization ability of deep neural networks is a central topic in deep learning theory. It is widely believed that "flat" minima—regions where the loss increases slowly in response to parameter perturbations—generalize better than "sharp" ones. However, defining a mathematically rigorous and theoretically sound measure of flatness has proven challenging.

The Challenge of Scale Invariance

A critical issue identified by researchers is that ReLU-based networks are scale-invariant. For any positive scalar $a$, $ReLU(ax) = a \cdot ReLU(x)$. Consequently, one can scale the weights of one layer by $a$ and the subsequent layer by $1/a$ without altering the network's output function.

While the function remains identical, traditional flatness measures based on the Hessian of the loss are not invariant to such transformations. A "flat" minimum can be mathematically transformed into a "sharp" one through simple weight scaling, undermining the predictive value of these metrics. This lack of invariance means that traditional sharpness cannot be the fundamental explanation for generalization.

A Reparameterization-Invariant Measure

To address this, we propose a modified flatness measure that accounts for the weight scale. The core idea is to multiply the Hessian-based metric by the squared norm of the weights. Specifically, we define a flatness measure $\kappa$ as:

$$\kappa(w) := \|w\|^2 \cdot \lambda_{max}^H(w)$$

where $\|w\|^2$ is the squared Frobenius norm of the weights and $\lambda_{max}^H$ is the largest eigenvalue of the Hessian. We prove that this measure is invariant to layer-wise reparameterization. When weights are scaled, the change in the weight norm exactly compensates for the change in the Hessian's eigenvalues.

Beyond the maximum eigenvalue, we also consider a measure based on the Trace of the Hessian ($Tr(H)$), which captures the average curvature across all parameter directions:

$$\kappa_\tau^l(w) := \|w_l\|^2 \cdot Tr(H(w_l))$$

Figure 1: Comparison of flatness measures with and without the weight norm compensator. The proposed invariant measures (blue) maintain consistent correlations despite reparameterization.

Experimental Validation

We evaluated the proposed measures on CIFAR-10 (using LeNet-5) and MNIST (using a multi-layer perceptron). By varying hyperparameters such as batch size, learning rate, and initialization, we generated a diverse set of minima to test the correlation between our measures and actual generalization error.

Our experiments confirm that the proposed invariant measures are robust to random reparameterizations. While traditional Hessian measures lose their predictive power when layers are scaled, our metric remains stable, as illustrated in Figure 1.

Key Results: Trace vs. Max Eigenvalue

As shown in Figure 3, the trace-based invariant measure exhibits a remarkably strong correlation with generalization error ($\rho = 0.91$), significantly outperforming the measure based on the maximum eigenvalue ($\rho = 0.62$).

Figure 3: Correlation between the proposed invariant flatness measures and generalization error on CIFAR-10. The trace-based measure (right) shows a significantly higher correlation than the max-eigenvalue-based measure (left).

This suggests that the "full spectrum" of the loss surface matters. The average flatness across all directions (captured by the trace) is a more reliable predictor of model performance than the worst-case sharpness in a single direction.

Conclusion and Future Work

This work provides a theoretically grounded approach to measuring flatness in deep neural networks. By introducing reparameterization invariance, we resolve a major theoretical inconsistency in the study of generalization. While the current study focuses on ReLU networks and layer-wise invariance, future work could extend these measures to neuron-wise invariance and more complex architectures like Transformers. Furthermore, using these invariant measures as regularizers during training presents a promising avenue for actively improving model generalization.

Summary updated

BibTeX
@misc{petzka2019reparameterization,
  author = {Henning Petzka and Linara Adilova and Michael Kamp and Cristian Sminchisescu},
  title = {{A Reparameterization-Invariant Flatness Measure for Deep Neural Networks}},
  year = {2019},
  eprint = {1912.00058},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.00058},
}
Figure