An Investigation into Neural Net Optimization via Hessian Eigenvalue Density

Behrooz Ghorbani, Shankar Krishnan, Ying Xiao

TL;DR

Researchers have developed a highly scalable tool to peer into the "curvature" of deep neural networks by estimating their full Hessian eigenvalue spectrum. Their findings reveal that Batch Normalization (BN) speeds up training primarily by suppressing massive "outlier" eigenvalues that otherwise trap gradients in unproductive, high-curvature directions.

What Problem Does This Paper Address?

The Hessian matrix (the matrix of second-order partial derivatives of the loss function) is the "holy grail" for understanding neural network optimization. Its eigenvalues define the local curvature of the loss landscape: large eigenvalues mean steep, sharp valleys, while small ones mean flat regions.

However, for modern networks with millions of parameters ($n$), the Hessian is an astronomical $n \times n$ matrix. Calculating its eigenvalues exactly requires $O(n^3)$ operations, which is computationally impossible for anything larger than a toy model. Consequently, researchers have long relied on proxies, visualizations, or only the top few eigenvalues to guess how the loss landscape behaves. This paper aims to bridge that gap by providing a way to see the entire spectrum for ImageNet-scale models.

Methods

The authors adapt a technique from numerical linear algebra called Stochastic Lanczos Quadrature.

  1. Pearlmutter’s Trick: Instead of building the massive Hessian matrix explicitly, they use a trick to compute Hessian-vector products ($Hv$). This is efficient because it only requires two passes of backpropagation.
  2. Lanczos Algorithm: They use these $Hv$ products to iteratively build a small tridiagonal matrix that captures the essential spectral properties of the full Hessian.
  3. Quadrature & Smoothing: They apply a quadrature rule to estimate the eigenvalue density and convolve the results with a Gaussian kernel to produce a smooth, readable "spectral density" plot.
  4. Distributed Implementation: To handle models like Inception V3, they built a distributed system in TensorFlow that parallelizes these computations across multiple GPUs.

The tool is remarkably accurate; when tested on a small MNIST model where exact values could be computed, the estimator achieved double-precision accuracy ($10^{-14}$).

Comparison of estimated vs. exact Hessian density on a small model.

Datasets

The study evaluates the Hessian spectrum across several standard benchmarks:

  • MNIST: Used for small-scale validation and error analysis.
  • CIFAR-10: Used to study ResNet-32 and VGG-11 architectures.
  • ImageNet: Used for large-scale testing on ResNet-18 and Inception V3.

Key Insights and Ideas

  • The "Vanishing" Negative Curvature: At initialization, the spectrum is dominated by large negative eigenvalues (indicating many "downhill" directions). However, these disappear almost instantly—within the first 1% of training steps—leaving a spectrum that is mostly positive or near zero.
Figure 2: The evolution of the spectrum of a Resnet-32 in the beginning of training. After just 400 momentum steps, large negative eigenvalues disappear.
  • Batch Norm as an Outlier Suppressor: In networks without Batch Normalization, a few "outlier" eigenvalues grow massive, far away from the "bulk" of the spectrum near zero. BN effectively pushes these outliers back into the bulk, creating a smoother, more well-conditioned landscape.
  • Gradient Concentration: The authors found a "pernicious" effect in non-BN networks: nearly 99% of the gradient energy concentrates in the subspaces of these few outlier eigenvalues. Because these directions have extreme curvature, the optimizer is forced to use a tiny learning rate, slowing down progress in the flatter directions where the actual "path" to the optimum lies.
  • Challenging Conventional Wisdom:
    • Learning Rate Drops: Common intuition suggests lower learning rates let models slip into "sharper" crevices. The authors observed the opposite: after a learning rate drop, the spectrum actually contracted, becoming less sharp.
  • Residual Connections: While often thought to "smooth" the landscape, the authors found that adding residual connections actually made the Hessian spectrum wider (more high-curvature eigenvalues) compared to versions without them, contradicting some popular visualization-based theories.
Figure 4: Spectral densities of Resnet-32 preceding and following a learning rate decrease (at step 40000). The Hessian prior to the learning rate drop appears sharper.

Key Results

  • Scalability: The tool can generate the spectrum for a ResNet-18 on ImageNet in about 20 hours—roughly half the time it takes to train the model itself.
  • BN Intervention: To prove BN's role, the authors trained a model using "population statistics" (fixed mean/variance) instead of mini-batch statistics. This caused the outliers to reappear and the training speed to plummet, confirming that the stochasticity of mini-batch BN is what helps suppress outliers.
  • Residual Connection Impact: Figure 5 shows that while residual connections are vital for training deep nets, they don't necessarily "smooth" the Hessian in the way previously hypothesized.
Figure 5: Spectral densities of Resnet-32 with and without residual connections (at step 40000). The Hessian without residual connections appears to be smoother.

Limitations and Future Work

  • Computational Overhead: While "scalable," the method still requires hundreds of full-batch Hessian-vector products, making it expensive for routine use during every training run.
  • Generalization: The paper focuses heavily on optimization speed. The link between the full Hessian spectrum and generalization (how well the model performs on new data) remains a promising but largely unexplored frontier.
  • Architectural Scope: The study primarily looks at ResNets and VGG. How these spectral dynamics change in Transformers or GANs remains to be seen.

Summary updated

Abstract

To understand the dynamics of optimization in deep neural networks, we develop a tool to study the evolution of the entire Hessian spectrum throughout the optimization process. Using this, we study a number of hypotheses concerning smoothness, curvature, and sharpness in the deep learning literature. We then thoroughly analyze a crucial structural feature of the spectra: in non-batch normalized networks, we observe the rapid appearance of large isolated eigenvalues in the spectrum, along with a surprising concentration of the gradient in the corresponding eigenspaces. In batch normalized networks, these two effects are almost absent. We characterize these effects, and explain how they affect optimization speed through both theory and experiments. As part of this work, we adapt advanced tools from numerical linear algebra that allow scalable and accurate estimation of the entire Hessian spectrum of ImageNet-scale neural networks; this technique may be of independent interest in other applications.
BibTeX
@inproceedings{ghorbani2019investigation,
  author = {Behrooz Ghorbani and Shankar Krishnan and Ying Xiao},
  title = {{An Investigation into Neural Net Optimization via Hessian Eigenvalue Density}},
  booktitle = {International Conference on Machine Learning},
  year = {2019},
  url = {https://openreview.net/forum?id=HyN9ejbdWr},
}
Figure