PyHessian: Neural Networks Through the Lens of the Hessian

Zhewei Yao, Amir Gholami, Kurt Keutzer, Michael Mahoney
12/16/2019
cs.LGmath.NA

Official code: amirgholami/PyHessian (794 stars, MIT, last commit 2025-07-10).

Abstract

We present PYHESSIAN, a new scalable framework that enables fast computation of Hessian (i.e., second-order derivative) information for deep neural networks. PYHESSIAN enables fast computations of the top Hessian eigenvalues, the Hessian trace, and the full Hessian eigenvalue/spectral density, and it supports distributed-memory execution on cloud/supercomputer systems and is available as open source. This general framework can be used to analyze neural network models, including the topology of the loss landscape (i.e., curvature information) to gain insight into the behavior of different models/optimizers. To illustrate this, we analyze the effect of residual connections and Batch Normalization layers on the trainability of neural networks. One recent claim, based on simpler first-order analysis, is that residual connections and Batch Normalization make the loss landscape smoother, thus making it easier for Stochastic Gradient Descent to converge to a good solution. Our extensive analysis shows new finer-scale insights, demonstrating that, while conventional wisdom is sometimes validated, in other cases it is simply incorrect. In particular, we find that Batch Normalization does not necessarily make the loss landscape smoother, especially for shallower networks.

View on arXivView PDF

Code Implementations(1)

MIT

PyHessian is a Pytorch library for second-order based analysis and training of Neural Networks

794128Python, Jupyter NotebookNov 20, 20191 years agoMIT
hessianhessian-freepytorch-librarysecond-ordersecond-order-optimization

Similar Papers

Cite this paper

@article{yao2019pyhessian,
  title  = {PyHessian: Neural Networks Through the Lens of the Hessian},
  author = {Zhewei Yao and Amir Gholami and Kurt Keutzer and Michael Mahoney},
  year   = {2019},
  eprint = {1912.07145},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1912.07145}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1912.07145.svg)](https://codeofpaper.com/paper/1912.07145)

Discussion