# The Hessian rank bounds the learning coefficient

**TL;DR:** In a neural network with $d$ parameters, the (local) learning coefficient $\lambda$ can be upper and lower bounded by the rank of the network's Hessian $d_1$:

$\frac{d_1}{2} \leq \lambda \leq \frac{d_1}{2}+\frac{d-d_1}{4}$.

The lower bound is a known result. The upper bound is a claim by me, and this post contains the proof for it.[^glz8wlwh5u5] If you find any problems, do point them out. 

*Edit 16.08.2024: The original version of this post had a three in the denominator of the upper bound.* [*Dmitry Vaintrob*](https://www.lesswrong.com/users/dmitry-vaintrob) *spotted an improvement to make it a four.*

Introduction
============

The learning coefficient $\lambda$ is a measure of loss basin volume and model complexity. You can think of it sort of like an effective parameter count of the neural network. Simpler models that do less stuff have smaller $\lambda$.

Calculating $\lambda$ for real networks people actually use is a pain. My hope is that these bounds help make estimating it a bit easier.

In a network with $d$ parameters, the learning coefficient is always a number

$0\leq\lambda \leq \frac{d}{2}$.

An existing result in the literature says that if you’ve calculated the rank of the network’s Hessian $d_1$,[^8dnv4nthfzo] you get a tighter lower bound

$\frac{d_1}{2} \leq \lambda.$

I claim that we can also get a tighter upper bound

$\lambda \leq \frac{d_1}{2}+\frac{d-d_1}{4}$,

where $d-d_1$ will be the dimension of the Hessian kernel, meaning the number of zero eigenvalues it has.[^nlhqziet23]

This is neat because it means we can get some idea of how large $\lambda$ is using only standard linear algebra methods. All we need to know is how many zero eigenvalues the Hessian has.[^kpcl2d68qn] Singular Learning Theory introductions often stress that just looking at the Hessian isn’t enough to measure basin volume correctly. But here we see that if you do it right, the Hessian eigenspectrum can give you a pretty good idea of how large $\lambda$ is. Especially if there aren't that many zero eigenvalues.

Intuitively, the lower bound works because a direction  in the parameters $w$ that isn't free to vary to second order in the Taylor expansion won't become any more free to vary if you pile on a bunch of higher order terms. The Second order term strictly dominates the higher order ones, they can't cancel it out.

Qualitatively speaking, the upper bound works for the same reason. The higher order terms in the Taylor expansion of the loss can only matter so much. The Hessian is the leading term, so it can impact $\lambda$ the most, adding $\frac{1}{2}$ per Hessian rank to it. The remaining terms of order $\mathcal{O}(w^3)$ and above can only add a maximum of $\frac{1}{4}$ for the remaining directions. 

The proof for the upper bound will just be a small modification of the proof for theorem 7.2 on pages 220 and 221 of Algebraic Geometry and Statistical Learning Theory. Maybe read that first if you want more technical context.

Some words on notation
----------------------

In the following, I’ll mostly stick to the notation and conventions of the book Algebraic Geometry and Statistical Learning Theory. You can read about all the definitions there. I'm too lazy to reproduce them all. 

To give some very rough context, $K(w)$ is sort of like the 'loss' at parameter configuration $w$, $\varphi(w)$ is our prior over parameters, and $Z(n)$ is the partition function after updating on $n$ data points.[^g2m0vdlo2qt]

Theorem:
========

Let $W \subset \mathbb{R}^d$ be the set of parameters of the model. If there exists an open set $U \subset W$ such that

$\{w \in U:\,K(w)=0,\,\,\,\,\varphi(w)>0\}$

is not an empty set, and we define $d_1=$ rank$(H)$ as the rank of the Hessian $H$ at a $w_0 \in U$

$H_{i,j} = \frac{\partial^2 K(w)}{\partial w_i \partial w_j}\vert_{w=w_0}$

with $w_i,w_j$ elements of some orthonormal basis $\{w_1,\dots w_d\}$ of $\mathbb{R}^d$, then

$\lambda \leq \frac{d_1}{2}+\frac{d-d_1}{4}$.

Proof:
======

We can assume $w_0=0$ without loss of generality. If $\epsilon_1, \epsilon_2$ are sufficiently small constants,

$Z(n)= \int \exp{(-n K(w))} \varphi(w) dw \geq \int\limits_{\vert w^{(1)} \vert \leq \epsilon_1, \vert w^{(2)} \vert \leq \epsilon_2} \exp{\{-n K(w)\}} \varphi(w) dw\,.$

Here,  $w^{(1)} \in W/\text{ker}{(H)}, w^{(2)} \in \text{ker}{(H)}$.

If we pick $\{w_1,\dots w_d\}$ to be the Hessian eigenbasis, then for sufficiently small $\vert w \vert >0$

$K(w) = \frac{1}{2} \sum\limits^{d_1}_{i,i=1} H_{i,i} w^{(1)}_i w^{(1)}_i +\mathcal{O}(\vert w^{(1)}\vert^2 \vert w^{(2)}\vert)+\mathcal{O}(\vert w^{(2)}\vert^2 \vert w^{(1)}\vert)+\mathcal{O}(\vert w\vert^4)$.

There is no $\mathcal{O}(\vert w^{(2)}\vert^3)$ term because we are at a local optimum, so no direction can have a leading term that is an odd power.  
  
For sufficiently large $n$, transforming $Z(n)$ by ${w'}^{(1)}= n^{\frac{1}{2}} w^{(1)}, \, {w'}^{(2)}= n^{\frac{1}{4}} w^{(2)}$ yields  
  
$Z(n)\geq n^{-\frac{d_1}{2}}n^{-\frac{d-d_1}{4}} \int\limits_{\vert {w'}^{(1)} \vert \leq 1, \vert {w'}^{(2)} \vert \leq 1} \exp{\{-n K({w'}^{(1)},{w'}^{(2)}\}} \varphi\left(n^{-\frac{1}{2}}{w'}^{(1)},n^{-\frac{1}{4}}{w'}^{(2)}\right) dw'\,.$

Rearranging and substituting gives

$Z(n)n^{\frac{d_1}{2}+\frac{d-d_1}{3}}\geq \int\limits_{\vert {w'} \vert \leq 1} \exp{\{-\frac{1}{2} \sum^{d_1}_{i=1} H_{i,i} {w'}^{(1)}_i {w'}^{(1)}_i +n^{-\frac{1}{4}}\mathcal{O}(\vert {w'}^{(1)}\vert^2 \vert {w'}^{(2)}\vert)+\mathcal{O}(\vert {w'}^{(2)}\vert^2 \vert {w'}^{(1)}\vert)+\mathcal{O}(\vert {w'}\vert^4)}\} \varphi\left(n^{-\frac{1}{2}} w'^{(1)},n^{-\frac{1}{4}} w'^{(2)}\right) d{w'}\,.$

The right-hand side will converge to a positive constant $c>0$ as $n\rightarrow \infty$:

$\int\limits_{\vert {w'} \vert \leq 1} \exp{\{-\frac{1}{2} \sum^{d_1}_i H_{i,i} w'^{(1)}_i {w'}^{(1)}_i + \mathcal{O}(\vert {w'}^{(2)} \vert^2 \vert {w'}^{(1)} \vert) +\mathcal{O}(\vert {w'}^{(2)} \vert^4)\}} \varphi(0) dw'= c$ .

Thus, we have 

$\lim\limits_{n\rightarrow \infty} Z(n)n^{\frac{d_1}{2}+\frac{d-d_1}{4}}\geq c$   .                   (1)

By Theorem 7.1(1), page 218 of Algebraic Geometry and Statistical Learning Theory,[^gmhsri1bgck] we also know 

$\lim\limits_{n\rightarrow \infty} Z(n) \frac{n^{\lambda}}{{(\log n)}^{m-1}} = c^*$  ,                  (2)

where $c^*>0$ is some positive constant and $m$ is the order of the largest pole of 

$\zeta(z)= \int K(w)^z \varphi(w) dw$.

Putting (1) and (2) together, we get

$\lambda \leq \frac{d_1}{2}+\frac{d-d_1}{4}$.

Future work
===========

I think it is possible to prove progressively tighter upper and lower bounds for the learning coefficient $\lambda$ using information from progressively higher-order terms in the Taylor expansion of the loss.

For example, if the third and fourth-order terms involving $w^{(2)}$  happened to all be zero as well for a particular model, we could've transformed $w'^{(2)}= n^{\frac{1}{6}} w^{(2)}$ in the proof instead, and obtained the even tighter upper bound $\lambda \leq \frac{d_1}{2}+\frac{d-d_1}{6}$.

I have some early results for an upper bound formula like this, though right now it only works under specific conditions[^sedaz0dljio].

Since the higher-dimensional tensors in these $\mathcal{O}(\vert w\vert^n)$ terms can be very computationally intensive to deal with, the real challenge in making these progressively stricter bounds for $\lambda$ practically useful would be finding tricks to make handling those tensors cheaper. A SPAR team I'm mentoring is currently trying out some ideas on that front on real networks.

Acknowledgments
---------------

Credit to Dmitry Vaintrob for spotting the improvement that tightened the upper bound from $\frac{d_1}{2}+\frac{d-d_1}{3}$ in the original version of this post to $\frac{d_1}{2}+\frac{d-d_1}{4}$. Thanks to Daniel Murfet for discussion and feedback on the proof idea.

[^glz8wlwh5u5]: I couldn’t find the upper bound in the literature and Daniel Murfet hadn’t heard of it either, which is why I wrote this. But it could be around somewhere and I just missed it. 

[^8dnv4nthfzo]: For the learning coefficient, this will be the smallest Hessian rank out of all points in the set of minimum loss. For the local learning coefficient, it'll be the smallest Hessian rank out of all minimum loss points in the local neighbourhood we specify. 

[^nlhqziet23]: This will hold for the Hessian rank at any point with minimum loss, though the upper bound from the point with the smallest Hessian rank will of course be the tightest. 

[^kpcl2d68qn]: Or, in practice, how many Hessian eigenvalues are numerically small enough to not matter at the noise scale we choose. 

[^g2m0vdlo2qt]: I.e. the integral of our Bayesian posterior over the parameters after updating on \(n\) data points. 

[^gmhsri1bgck]: Careful, at least my version of the book has a typo here. I think the fraction should be the other way around from the way it's written in the book. 

[^sedaz0dljio]: Only for MSE loss, and only if we are at a global optimum where we match the output labels exactly.