Abstract
We introduce a fast algorithm for entry-wise evaluation of the Gauss-Newton Hessian (GNH) matrix for the fully-connected feed-forward neural network. The algorithm utilizes a precomputation step and an importance-based sampling step to reduce the cost of computing a matrix entry from $O(Nn)$ to $O(n+d/\epsilon^2)$, where $N$ is the number of parameters, $n$ is the number of data points, and $d$ is the output dimension. This efficiency enables the construction of hierarchical-matrix ($\mathcal{H}$-matrix) approximations, significantly reducing memory and computational requirements for second-order optimization tasks.
Introduction
Second-order optimization methods, which utilize the Hessian matrix, offer superior convergence properties compared to first-order methods like SGD. However, for a network with $N$ parameters, the $N \times N$ Hessian is often too large to store or compute. For $N=10^6$, the Hessian contains $10^{12}$ entries. Standard computation of a single column requires $O(Nn)$ work, making direct access to the matrix entries computationally prohibitive. This paper addresses the "entry-wise evaluation" problem, proposing a method to quickly access specific parts of the GNH matrix without full computation.
Methodology
Precomputation and Fast Sampling
The proposed approach tames the GNH through a two-stage process. First, a precomputation step exploits the layer-by-layer structure of the MLP to store intermediate matrices representing a compressed Jacobian. This reduces storage requirements from $O(N^2)$ to $O(nN)$. Second, a fast Monte Carlo sampling algorithm uses importance sampling to estimate entries $H_{km}$ by drawing a small number of samples based on the precomputed values. This reduces the cost per entry to $O(n + d/\epsilon^2)$, making the sampling step independent of the number of parameters $N$.
Hierarchical Matrix Approximation
By enabling cheap entry-wise access, the authors construct an $\mathcal{H}$-matrix approximation using the Geometry-Oblivious Fast Multipole Method (GOFMM). This method treats the GNH as a tree structure where "near" parameters (defined by algebraic distance within the GNH itself) are stored densely, while "far" parameters are approximated as low-rank blocks. This allows for efficient storage and factorization, reducing memory footprint to $O(N r_o)$ and factorization work to $O(N r_o^2)$.
Key Results
The method was evaluated on MNIST and CIFAR-10 datasets with networks up to 1.6M parameters.
- Massive Memory Savings: For a 1.6M parameter network, the precomputation required only 423 MB, compared to the 10.8 TB required for a full GNH—a 25,000x reduction.
- High Accuracy: The $\mathcal{H}$-matrix approximation achieved high precision (up to 4 digits) and outperformed standard methods like K-FAC and Randomized SVD (RSVD) on autoencoder tasks where the Hessian spectrum decays slowly.
Conclusion
This work demonstrates that the $N$-dependency in Hessian evaluation can be broken, allowing for advanced linear algebra tools to be applied to deep learning. Future work includes extending this framework to Convolutional Neural Networks (CNNs) and integrating the approximation into full training loops to evaluate real-world speedups.
Summary updated