Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Linearised Laplace approximations

The previous chapter showed a computationally lightweight Gaussian approximation N(θ;θ∗,Ψ(θ∗)−1)\mathcal{N}(\theta;\theta_*, \precision(\theta_*)^{-1}) to the true posterior p(θ∣D)p(\theta \mid \mathcal{D}) on the parameter space RP\mathbb{R}^{P}. Our final goal is to use this Gaussian measure to make decisions based on the model’s output: its predictions feed into the risks and utilities that downstream tasks optimise (Chapter Analytic, low-cost functionality from Laplace). To this end, we first quantify the predictive uncertainty of our network on the output space RC\mathbb{R}^{C} by turning it into a Gaussian process (GP). Figure 1 previews the pipeline, from the maximum a posteriori (MAP) estimate θ∗\theta_* to the predictive distribution.

The linearised Laplace pipeline. The linearised network f^{\theta_*} and parameter covariance \Sigma=\precision(\theta_*)^{-1} jointly determine the logit Gaussian process, which induces a predictive distribution.

Figure 1:The linearised Laplace pipeline. The linearised network fθ∗f^{\theta_*} and parameter covariance Σ=Ψ(θ∗)−1\Sigma=\precision(\theta_*)^{-1} jointly determine the logit Gaussian process, which induces a predictive distribution.

Linearisation

To turn an arbitrary (differentiable) neural network parameterised by θ∈RP\theta \in \mathbb{R}^P into a Gaussian process, we use two ingredients: linearisation in the parameter space and the previously introduced Laplace approximation.

We first introduce the concept of the linearised network fθ0 ⁣:RD×RP→RCf^{\theta_0}\colon \mathbb{R}^{D} \times \mathbb{R}^{P} \to \mathbb{R}^{C} as the first-order Taylor approximation of network ff around parameters θ0∈RP\theta_0 \in \mathbb{R}^{P}:

fθ0(x,θ):=f(x,θ0)+Jθf(x,θ0)(θ−θ0),f^{\theta_0}(x, \theta) := f(x, \theta_0) + \jaclogit(x, \theta_0)(\theta - \theta_0),

where Jθf(x,θ0)∈RC×P\jaclogit(x, \theta_0) \in \mathbb{R}^{C \times P} is the network Jacobian evaluated at (x,θ0)(x, \theta_0).[1] Analogously to Equation (1), we define the regularised empirical risk of the linearised network fθ0f^{\theta_0} with parameters θ\theta as

LΩθ0(θ):=∑n=1Nℓ(fθ0(xn,θ),yn)+Ω(θ).\regrisk^{\theta_0}(\theta) := \sum_{n=1}^N \ell\left(f^{\theta_0}(x_n,\theta),y_n\right) + \Omega(\theta).

Unless explicitly stated otherwise (e.g., in the prior-only discussion in Section The Prior), we fix the linearisation point at a minimiser of the original regularised empirical risk LΩ(θ)\regrisk(\theta):

θ∗:∈arg min⁡θ∈RPLΩ(θ),\theta_* :\in \operatorname*{arg\,min}_{\theta\in\mathbb{R}^{P}} \regrisk(\theta),

that is, we set θ0≡θ∗\theta_0 \equiv \theta_*. Linearisation itself only requires differentiability of ff at θ0\theta_0. The Laplace approximation needs more: θ∗\theta_* must be a local minimiser of LΩ\regrisk with zero gradient, and the resulting precision must be positive definite after adding the prior curvature. We note that fθ∗f^{\theta_*} shares its value and its parameter Jacobian with ff at θ∗\theta_*, so ∇θLΩθ∗(θ∗)=∇θLΩ(θ∗)=0\nabla_\theta \regrisk^{\theta_*}(\theta_*)=\nabla_\theta \regrisk(\theta_*)=0 and θ∗\theta_* is a stationary point of LΩθ∗\regrisk^{\theta_*}, too. Because fθ∗f^{\theta_*} is affine in θ\theta, convexity of ℓ(⋅,y)\ell(\cdot,y) in zz makes each loss term convex in θ\theta; with a strictly convex Ω\Omega, the risk LΩθ∗\regrisk^{\theta_*} is then strictly convex in θ\theta, hence θ∗\theta_* is its unique minimiser.

Following Section Laplace approximations are local and differential, the Laplace approximation using the regularised empirical risk of the linearised network yields the parameter-space Gaussian measure N(θ;θ∗,Ψ(θ∗)−1)\mathcal{N}(\theta; \theta_*, \precision(\theta_*)^{-1}) with

[Ψ(θ)]ij=[∇θ∇θ⊤LΩθ∗(θ)]ij=∂2LΩθ∗(θ)∂θi∂θj.[\precision(\theta)]_{ij} = \left[\nabla_\theta \nabla_\theta^{\top} \regrisk^{\theta_*}(\theta)\right]_{ij} = \frac{\partial^2 \regrisk^{\theta_*}(\theta)}{\partial \theta_i \partial \theta_j}.

The curvature Ψ\precision of the linearised network’s regularised empirical risk differs from the Hessian in Equation (7) for networks that are not piecewise affine in their parameters (except at the non-generic parameter values where all training residuals vanish). The difference is that Ψ(θ∗)\precision(\theta_*), as defined in Equation (4), discards the network’s parameter curvature (and higher-order derivatives) and only retains the curvature of the loss function over the model outputs. The advantages of this modelling choice are summarised in Section Advantages of Using the Linearised Network.

An important property of Gaussian measures is their closure under affine transformations, stated formally below.

As such, the linearised network fθ∗f^{\theta_*} pushes the parameter posterior forward, via the affine map of Equation (1), to a Gaussian in the output space (the logit space in classification). In the network-output variable z∈RCz\in\mathbb{R}^{C} (the logits, which the loss ℓ(z,y)\ell(z,y) takes as its first argument), this measure is

N(z;f(x∗,θ∗),Jθf(x∗,θ∗)Ψ(θ∗)−1Jθf(x∗,θ∗)⊤).\mathcal{N}\left(z; f(x_*, \theta_*), \jaclogit(x_*, \theta_*) \precision(\theta_*)^{-1} \jaclogit(x_*, \theta_*)^{\top}\right).

This result already equips the network ff with a probability measure in its output space (or logit space in classification) for every input x∗x_*. A Gaussian process is an even more powerful construction, capable of modelling a Gaussian measure over any finite set of inputs, not just a single one. The linearised network fθ∗f^{\theta_*} equipped with its parameter-space Laplace approximation defines a Gaussian process GP(f(⋅,θ∗),k)\GP(f(\cdot, \theta_*), k) with the following (Mercer) kernel:

k(x,x′)=cov⁡(fθ∗(x,θ),fθ∗(x′,θ))=cov⁡(Jθf(x,θ∗)(θ−θ∗),Jθf(x′,θ∗)(θ−θ∗))=Jθf(x,θ∗)Ψ(θ∗)−1Jθf(x′,θ∗)⊤.\begin{align} k(x, x') &= \operatorname{cov}\left(f^{\theta_*}(x, \theta), f^{\theta_*}(x', \theta)\right) \\ &= \operatorname{cov}\left(\jaclogit(x, \theta_*) (\theta - \theta_*), \jaclogit(x', \theta_*) (\theta - \theta_*)\right) \\ &= \jaclogit(x, \theta_*) \precision(\theta_*)^{-1} \jaclogit(x', \theta_*)^{\top}. \end{align}

Advantages of Using the Linearised Network

We perform the Laplace approximation w.r.t. LΩθ∗\regrisk^{\theta_*} (with θ∗=arg min⁡θ∈RPLΩ(θ)\theta_* = \operatorname*{arg\,min}_{\theta\in\mathbb{R}^{P}} \regrisk(\theta)) instead of the regularised empirical risk of ff for multiple reasons.

First, the Hessian of the regularised empirical risk of ff (Equation (7)) is not guaranteed to be positive definite, preventing us from interpreting it as the inverse covariance matrix of our approximate Gaussian posterior over the parameters θ\theta.[2] In second-order optimisation, the lack of positive definiteness also prohibits using the inverse Hessian as a preconditioner. However, the Hessian of the regularised empirical risk of fθ∗f^{\theta_*}, with a strongly convex regulariser, is guaranteed to be positive definite.

Second, the Hessian of the regularised empirical risk of fθ∗f^{\theta_*} is considerably cheaper to use than that of ff, allowing Laplace approximations to scale to deep learning architectures (see Section The Fisher).

There are thus two uses of the linearised model. First, it defines the curvature Ψ\precision and hence the parameter-space Gaussian posterior approximation. Second, it defines the predictive pushforward in Equation (13). Earlier work on Laplace approximations for neural networks MacKay, 1992Ritter et al., 2018 sampled MM parameter configurations {θs}s=1M\{\theta_s\}_{s=1}^{M} from the parameter-space Gaussian and calculated predictive quantities from the nonlinear predictions {f(x,θs)}s=1M\{f(x, \theta_s)\}_{s=1}^{M}. This loses the exact output-space Gaussian distribution available from linearisation and yields no posterior GP. Lawrence (2000) shows empirically that this approach is prone to underfitting: the predictive becomes too uncertain even on in-distribution data points. Immer et al. (2021) identify the core reason for performance loss as a mismatch between the model in which we perform approximate Bayesian inference (the linearised network fθ∗f^{\theta_*}) and the model we use for prediction (the nonlinear network ff). Figure 2 visualises this underfitting and the low-density samples drawn under the true posterior. See also Immer et al. (2021, Fig. 3). By using the linearised network to make predictions and not only to calculate the curvature, the approximation remains internally consistent.

The same full Laplace posterior under two predictive rules on a one-dimensional regression example from the code accompanying . Both panels use the same parameter-space approximate posterior and the same ten parameter draws. They differ only in how each parameter draw becomes a function-space sample called a sample path in the GP literature. Panel (a) sends each draw through the linearised network f^{\theta_*}, the model consistent with the parameter-space Laplace approximation. Panel (b) sends the draws through the original nonlinear network f. Solid curves are predictive means; dashed curves show pointwise 95\% credible intervals. The linearised Laplace approximation in Panel (a) yields a GP; therefore, the output-space quantities are available in closed form. The (nonlinear) Laplace approximation in Panel (b) yields an intractable output mean and covariance, which we approximate with two million Monte Carlo samples. The nonlinear scheme is far more uncertain over the training inputs and its mean severely underfits. The linearised Laplace approximation yields consistent function-space uncertainty.

(a)

The same full Laplace posterior under two predictive rules on a one-dimensional regression example from the code accompanying . Both panels use the same parameter-space approximate posterior and the same ten parameter draws. They differ only in how each parameter draw becomes a function-space sample called a sample path in the GP literature. Panel (a) sends each draw through the linearised network f^{\theta_*}, the model consistent with the parameter-space Laplace approximation. Panel (b) sends the draws through the original nonlinear network f. Solid curves are predictive means; dashed curves show pointwise 95\% credible intervals. The linearised Laplace approximation in Panel (a) yields a GP; therefore, the output-space quantities are available in closed form. The (nonlinear) Laplace approximation in Panel (b) yields an intractable output mean and covariance, which we approximate with two million Monte Carlo samples. The nonlinear scheme is far more uncertain over the training inputs and its mean severely underfits. The linearised Laplace approximation yields consistent function-space uncertainty.

(b)

Figure 2:The same full Laplace posterior under two predictive rules on a one-dimensional regression example from the code accompanying Immer et al. (2021). Both panels use the same parameter-space approximate posterior and the same ten parameter draws. They differ only in how each parameter draw becomes a function-space sample called a sample path in the GP literature. Panel (a) sends each draw through the linearised network fθ∗f^{\theta_*}, the model consistent with the parameter-space Laplace approximation. Panel (b) sends the draws through the original nonlinear network ff. Solid curves are predictive means; dashed curves show pointwise 95%95\% credible intervals. The linearised Laplace approximation in Panel (a) yields a GP; therefore, the output-space quantities are available in closed form. The (nonlinear) Laplace approximation in Panel (b) yields an intractable output mean and covariance, which we approximate with two million Monte Carlo samples. The nonlinear scheme is far more uncertain over the training inputs and its mean severely underfits. The linearised Laplace approximation yields consistent function-space uncertainty.

The Prior

The Gaussian process determined by the posterior parameter-space covariance matrix Ψ−1\precision^{-1} is tied to the dataset D\mathcal{D}, as Ψ\precision is the Hessian of the linearised model’s regularised empirical risk over D\mathcal{D}. It is worth spending some time on the case when the neural network f ⁣:RD×RP→RCf\colon \mathbb{R}^{D}\times\mathbb{R}^{P}\to\mathbb{R}^{C} has not been exposed to any dataset D\mathcal{D} yet. In this case, the model’s behaviour is determined by its architecture and by the prior p(θ)p(\theta) over the parameters.

For a non-Gaussian parameter prior p(θ)p(\theta), a Laplace approximation to the prior is centred at a local maximum θ0\theta_0 of p(θ)p(\theta), analogously to Equation (6). Its precision is the negative log-prior Hessian,

Ψ=−∇θ∇θlog⁡p(θ0).\precision = -\nabla_\theta \nabla_\theta \log p(\theta_0).

For the construction that follows, we specialise to a Gaussian prior centred at the linearisation point,

p(θ)=N(θ;θ0,I),p(\theta) = \mathcal{N}(\theta; \theta_0, I),

where θ0\theta_0 can be any chosen initialisation. The prior’s mode is θ0\theta_0, so the linearisation and the Laplace approximation of the prior share the same centre, and the precision above evaluates to Ψ=I\precision = I. Pushing this prior through the linearised network gives the kernel k ⁣:RD×RD→RC×Ck\colon \mathbb{R}^{D} \times \mathbb{R}^{D} \to \mathbb{R}^{C \times C},

k(x,x′)=Jθf(x,θ0)(Jθf(x′,θ0))⊤.k(x, x') = \jaclogit(x, \theta_0) \left(\jaclogit(x', \theta_0)\right)^{\top}.

The kernel comes from the same pushforward as the posterior GP kernel in Equation (14). Compared with it, the data-dependent pair (θ∗,Ψ(θ∗))(\theta_*,\precision(\theta_*)) is replaced by the dataset-independent pair (θ0,I)(\theta_0,I). This kernel is known as the Neural Tangent Kernel (NTK) Jacot et al., 2018.[3] It differs from the neural network Gaussian process (NNGP) kernel: the NNGP kernel is the covariance of random network outputs f(x,θ)f(x,\theta) and f(x′,θ)f(x',\theta) under a random initialisation distribution, while the NTK is the covariance of the linearised network outputs fθ0(x,θ)f^{\theta_0}(x,\theta) and fθ0(x′,θ)f^{\theta_0}(x',\theta) under the prior N(θ;θ0,I)\mathcal{N}(\theta;\theta_0,I). As the network width is taken to infinity in a specific way, both kernels are convergent. Where these limits exist, they are different deterministic kernels.

The NTK determines the function-space trajectory of ff during full-batch gradient flow training on the average empirical loss via the Ordinary Differential Equation (ODE)

 d dtft(x)=−1N∑n=1Nkt(x,xn)∇zℓ(z,yn)∣z=ft(xn),\frac{\,\mathrm{d}}{\,\mathrm{d} t} f_t(x) = -\frac{1}{N} \sum_{n=1}^{N} k_t(x, x_n) \left.\nabla_z \ell(z,y_n)\right|_{z=f_t(x_n)},

where tt is the time variable of the gradient flow and ktk_t is the NTK of ftf_t. Jacot et al. (2018) show that in the infinite-width limit of fully-connected neural networks with the so-called NTK initialisation, the NTK stays constant during training, and the convergence of optimisation is related to the positive definiteness of the NTK. However, the NTK of regular, finite-width neural networks is not constant and must be recomputed at every evaluation point.

From a modelling perspective, putting an isotropic Gaussian prior over the parameters is seldom well-motivated. However, the framework of Laplace approximations is compatible with interpretable function-space priors. Cinquin et al. (2024) define Laplace priors using a prior Gaussian process. In particular, the negative log-prior is, up to an additive constant, equal to the squared Reproducing Kernel Hilbert Space (RKHS) norm of the difference between the linearised network fθ0f^{\theta_0} and the mean of the prior Gaussian process μ\mu. This negative log-prior is also used as a regulariser during training. As specifying the Gaussian prior in the function space only requires knowledge about the function’s behaviour and not about the parameter space’s structure, the framework of Cinquin et al. (2024) allows domain experts to directly encode functional behaviour in the Bayesian inference problem.

The Fisher

In Section Linearisation, we glossed over the curvature matrix defined in Equation (4). This matrix and its components give an information-geometric interpretation to Laplace approximations, warranting its own chapter (Chapter The differential geometric perspective on Laplace).

Consider the regularised empirical risk of the linearised network fθ0f^{\theta_0} (Equations (1) and (2)). Under the assumption of Equation (2) applied to the linearised network, the term

Lθ0(θ)=∑n=1Nℓ(fθ0(xn,θ),yn)\mathcal{L}^{\theta_0}(\theta) = \sum_{n=1}^N \ell\left(f^{\theta_0}(x_n,\theta),y_n\right)

is equal, up to an additive constant, to the negative log-likelihood of the dataset under the model, −log⁡p(Y∣X,θ)-\log p(Y \mid X, \theta), whereas the term Ω(θ)\Omega(\theta) equals the negative log-prior, −log⁡p(θ)-\log p(\theta), again up to an additive constant.

Writing out the Hessian of Lθ0\mathcal{L}^{\theta_0} evaluated at θ0\theta_0, we obtain

G(θ0)=∇θ∇θ⊤Lθ0(θ0)=∑n=1N(Jθf(xn,θ0))⊤(∇z∇z⊤ℓ(z,yn)∣z=fθ0(xn,θ0))Jθf(xn,θ0),\ggn(\theta_0) = \nabla_\theta \nabla_\theta^{\top} \mathcal{L}^{\theta_0}(\theta_0) = \sum_{n = 1}^{N} \left(\jaclogit(x_n, \theta_0)\right)^{\top} \left(\nabla_{z}\nabla_{z}^{\top} \ell(z, y_n)\big|_{z = f^{\theta_0}(x_n, \theta_0)}\right) \jaclogit(x_n, \theta_0),

called the Generalised Gauss-Newton matrix (GGN). In this section, we show that this matrix is equivalent to the Fisher Information Matrix for a family of loss functions, which is a natural (usually degenerate) Riemannian metric for statistical manifolds parameterised by the model (Section The Fisher Metric).

Consider the statistical manifold

M={p(x,y∣θ):θ∈RP}\mathcal{M} = \left\{p(x, y \mid \theta) : \theta \in \mathbb{R}^{P}\right\}

with conditional independence structure p(x,y∣θ)=p(y∣x,θ)⋅p(x)p(x, y \mid \theta) = p(y \mid x, \theta)\cdot p(x), whose in-depth study we defer to Chapter The differential geometric perspective on Laplace. The p(y∣x,θ)p(y \mid x, \theta) distribution represents the likelihood parameterised by a neural network and p(x)p(x) is the ground-truth input distribution. A natural notion of separation between probability distributions on this manifold is the Kullback-Leibler (KL) divergence:

DKL(p(x,y∣θ1) ∥ p(x,y∣θ2)):=Ep(x,y∣θ1)[log⁡p(x,y∣θ1)p(x,y∣θ2)].D_{\text{KL}}\left(p(x, y \mid \theta_1)\ \Vert\ p(x, y \mid \theta_2)\right) := \mathbb{E}_{p(x, y \mid \theta_1)}\left[\log\frac{p(x, y \mid \theta_1)}{p(x, y \mid \theta_2)}\right].

The KL divergence is not a valid metric, as it is non-symmetric. However, for parameters θ1\theta_1 and θ2\theta_2 and Δθ=θ1−θ2\Delta\theta = \theta_1 - \theta_2, the KL divergence’s second-order Taylor approximation around θ1\theta_1 is given by

DKL(p(x,y∣θ1) ∥ p(x,y∣θ2))=12Δθ⊤F(θ1)Δθ+O(∥Δθ∥3).D_{\text{KL}}\left(p(x, y \mid \theta_1)\ \Vert\ p(x, y \mid \theta_2)\right) = \frac{1}{2}\Delta\theta^{\top} \fisher(\theta_1)\Delta\theta + \mathcal{O}\left(\Vert \Delta\theta\Vert^3\right).

Both the zeroth- and first-order terms vanish (the former because DKL(p ∥ p)=0D_{\text{KL}}(p\ \Vert\ p)=0, the latter because the expected score is zero, Equation (27)), leaving the quadratic Fisher term as the leading contribution. At each parameter θ\theta, the bilinear form gθ(u,v):=u⊤F(θ)vg_\theta(u, v) := u^{\top} \fisher(\theta) v on tangent vectors u,vu, v is a valid Riemannian metric over manifold M\mathcal{M} (up to the identifiability of parameters; see Chapter The differential geometric perspective on Laplace). The matrix

F(θ)=Ep(x,y∣θ)[−∇θ∇θ⊤log⁡p(x,y∣θ)]\fisher(\theta) = \mathbb{E}_{p(x, y \mid \theta)}\left[-\nabla_{\theta}\nabla_{\theta}^{\top} \log p(x, y \mid \theta)\right]

is called the Fisher Information Matrix (FIM) of the random variable (X,Y)(\mathrm X, \mathrm Y) distributed according to p(x,y∣θ)p(x, y \mid \theta).

Differentiating the normalisation ∫p(x,y∣θ) dx dy=1\int p(x, y \mid \theta) \,\mathrm{d} x \,\mathrm{d} y = 1 under the integral sign and using ∇θp=p∇θlog⁡p\nabla_\theta p = p \nabla_\theta \log p gives the zero-mean score,

Ep(x,y∣θ)[∇θlog⁡p(x,y∣θ)]=0.\mathbb{E}_{p(x, y \mid \theta)}\left[\nabla_\theta \log p(x, y \mid \theta)\right] = 0.

Differentiating once more yields the two equivalent forms of the Fisher information,

F(θ)=Ep(x,y∣θ)[−∇θ∇θ⊤log⁡p(x,y∣θ)]=Ep(x,y∣θ)[∇θlog⁡p(x,y∣θ)(∇θlog⁡p(x,y∣θ))⊤].\fisher(\theta) = \mathbb{E}_{p(x, y \mid \theta)}\left[-\nabla_\theta \nabla_\theta^{\top} \log p(x, y \mid \theta)\right] = \mathbb{E}_{p(x, y \mid \theta)}\left[\nabla_\theta \log p(x, y \mid \theta)\left(\nabla_\theta \log p(x, y \mid \theta)\right)^{\top}\right].

The FIM of independent random variables is additive. In particular, for NN i.i.d. random variables {(Xn,Yn)}n=1N\{(\mathrm X_n, \mathrm Y_n)\}_{n=1}^N, the FIM is NN times that of a single random variable (X,Y)(\mathrm X, \mathrm Y):

Ep({(xn,yn)}n=1N∣θ)[−∇θ∇θ⊤log⁡p({(xn,yn)}n=1N∣θ)]=∑n=1NEp(xn,yn∣θ)[−∇θ∇θ⊤log⁡p(xn,yn∣θ)]=NF(θ).\begin{align} &\mathbb{E}_{p\left(\{(x_n, y_n)\}_{n=1}^N \mid \theta\right)}\left[-\nabla_\theta \nabla_\theta^{\top} \log p\left(\{(x_n, y_n)\}_{n=1}^N \mid \theta\right)\right] \\ &= \sum_{n=1}^N \mathbb{E}_{p(x_n, y_n \mid \theta)}\left[-\nabla_\theta \nabla_\theta^{\top} \log p(x_n, y_n \mid \theta)\right] \\ &= N \fisher(\theta). \end{align}

In the following, we use the notation F(θ)\fisher(\theta) for the FIM of a single random variable (X,Y)(\mathrm X, \mathrm Y) distributed according to p(x,y∣θ)p(x, y \mid \theta).

Using Equation (25), the utility of the FIM becomes clear in second-order optimisation. In particular, consider the objective

arg min⁡Δθ∈RPL(θ+Δθ)s.t.DKL(p(x,y∣θ) ∥ p(x,y∣θ+Δθ))≤c\operatorname*{arg\,min}_{\Delta\theta \in \mathbb{R}^{P}} \mathcal{L}(\theta + \Delta \theta)\qquad \text{s.t.}\qquad D_\text{KL}(p(x, y \mid \theta)\ \Vert\ p(x, y \mid \theta + \Delta\theta)) \le c

for some constant c∈R>0c \in \mathbb{R}_{> 0}. The intuition behind this objective is that we want to minimise our model’s non-regularised empirical risk while limiting how much the likelihood induced by the model changes, irrespective of the curvature of the loss surface. To find an approximate minimiser of the objective in Equation (30), we consider the quadratic approximation to our constraint in Equation (25) and linearise the empirical risk around the current parameter θ\theta:

L(θ+Δθ)=L(θ)+Δθ⊤∇θL(θ)+O(∥Δθ∥2).\mathcal{L}(\theta + \Delta\theta) = \mathcal{L}(\theta) + \Delta\theta^{\top} \nabla_\theta \mathcal{L}(\theta) + \mathcal{O}\left(\Vert\Delta\theta\Vert^2\right).

Substituting in the linearised empirical risk and quadratic constraint, our objective becomes

arg min⁡Δθ∈RPΔθ⊤∇θL(θ)s.t.12Δθ⊤F(θ)Δθ≤c.\operatorname*{arg\,min}_{\Delta\theta \in \mathbb{R}^{P}} \Delta\theta^{\top} \nabla_\theta \mathcal{L}(\theta) \qquad \text{s.t.}\qquad \frac{1}{2}\Delta\theta^{\top} \fisher(\theta)\Delta\theta \le c.

The above is a convex quadratically constrained linear program. When F(θ)\fisher(\theta) is positive definite and ∇θL(θ)≠0\nabla_\theta\mathcal{L}(\theta)\neq 0, the optimum lies on the boundary of the constraint ellipsoid and can be found in closed form with Lagrange’s method, yielding

Δθ∗=−1λ∗F(θ)−1∇θL(θ),λ∗=(∇θL(θ))⊤F(θ)−1∇θL(θ)2c.\begin{align} \Delta\theta^* = -\frac{1}{\lambda^*}\fisher(\theta)^{-1}\nabla_\theta \mathcal{L}(\theta),\qquad\lambda^* = \sqrt{\frac{\left(\nabla_\theta \mathcal{L}(\theta)\right)^{\top} \fisher(\theta)^{-1}\nabla_\theta \mathcal{L}(\theta)}{2c}}. \end{align}

In particular, the optimal update direction Δθ∗\Delta\theta^* is given by the so-called natural gradient F(θ)−1∇θL(θ)\fisher(\theta)^{-1}\nabla_\theta \mathcal{L}(\theta) with a magnitude that is a function of the constant cc. Natural-gradient methods are developed in detail in Chapter Natural-gradient-based variational inference.

In practice, we replace the unknown distribution of inputs p(x)p(x) with the empirical distribution w.r.t. training set D\mathcal{D}:

p(x)≈pD(x)=1N∑n=1Nδ(x−xn).p(x) \approx p_{\mathcal{D}}(x) = \frac{1}{N} \sum_{n=1}^{N} \delta(x - x_n).

The corresponding FIM approximation becomes

F~(θ)=1N∑n=1NEp(y∣xn,θ)[−∇θ∇θ⊤log⁡p(y∣xn,θ)].\tilde{\fisher}(\theta) = \frac{1}{N} \sum_{n=1}^{N} \mathbb{E}_{p(y \mid x_n, \theta)}\left[-\nabla_{\theta}\nabla_{\theta}^{\top} \log p(y \mid x_n, \theta)\right].

Using the chain rule w.r.t. the model’s output z=f(xn,θ)z = f(x_n, \theta), we obtain

F~(θ0)=1N∑n=1N(Jθf(xn,θ0))⊤Ep(y∣xn,θ0)[−∇z∇z⊤log⁡p(y∣z)∣z=f(xn,θ0)]Jθf(xn,θ0).\tilde{\fisher}(\theta_0) = \frac{1}{N} \sum_{n=1}^{N} \left(\jaclogit(x_n, \theta_0)\right)^{\top} \mathbb{E}_{p(y \mid x_n, \theta_0)}\left[-\nabla_z\nabla_z^{\top} \log p(y \mid z)\big|_{z = f(x_n, \theta_0)}\right] \jaclogit(x_n, \theta_0).

Here the network’s own second-order term vanishes under the expectation by the zero-mean score in zz (Equation (27) applied to p(y∣z)p(y \mid z)), which is why the linearised and nonlinear networks share the same F~(θ0)\tilde{\fisher}(\theta_0). The expectation over model outputs for each input can be expensive to compute. One approach to mitigate the cost is the Monte Carlo approximation:

Ep(y∣xn,θ)[−∇z∇z⊤log⁡p(y∣z)∣z=f(xn,θ)]≈−1M∑s=1M∇z∇z⊤log⁡p(ys∣z)∣z=f(xn,θ),\mathbb{E}_{p(y \mid x_n, \theta)}\left[-\nabla_z\nabla_z^{\top} \log p(y \mid z)\big|_{z = f(x_n, \theta)}\right] \approx -\frac{1}{M}\sum_{s=1}^{M} \nabla_z\nabla_z^{\top} \log p(y_s \mid z)\big|_{z = f(x_n, \theta)},

with ys∼p(y∣xn,θ)y_s \sim p(y \mid x_n, \theta). For small MM, we obtain a rather crude but cheap approximation. An alternative approach is to first rewrite F~(θ)\tilde{\fisher}(\theta) as

F~(θ)=1N∑n=1NEp(y∣xn,θ)[∇θlog⁡p(y∣xn,θ)(∇θlog⁡p(y∣xn,θ))⊤]\tilde{\fisher}(\theta) = \frac{1}{N}\sum_{n=1}^N\mathbb{E}_{p(y \mid x_n, \theta)}\left[\nabla_{\theta}\log p(y \mid x_n, \theta) \left(\nabla_{\theta} \log p(y \mid x_n, \theta)\right)^{\top}\right]

(Equation (28), applied to p(y∣xn,θ)p(y \mid x_n, \theta)), then substitute the ground-truth labels instead of approximating the expectation:

F^(θ)=1N∑n=1N∇θlog⁡p(yn∣xn,θ)(∇θlog⁡p(yn∣xn,θ))⊤,\hat{\fisher}(\theta) = \frac{1}{N} \sum_{n=1}^{N} \nabla_{\theta}\log p(y_n \mid x_n, \theta) \left(\nabla_{\theta} \log p(y_n \mid x_n, \theta)\right)^{\top},

called the Empirical Fisher Information Matrix (EFIM). While this substitution may seem natural, Kunstner et al. (2019) show that it has a detrimental effect for optimisation, where the predicted and ground-truth labels can be significantly different, especially at the beginning of training. However, for the Laplace approximation, we use a MAP estimate, which, if it generalises well, approximates the ground-truth label distribution well.

For a wide family of likelihoods, one does not have to approximate the Fisher F~(θ)\tilde{\fisher}(\theta) by Monte Carlo. This allows us to connect the FIM to the GGN under some assumptions. Identifying ℓ(z,yn)=−log⁡p(yn∣z)\ell(z, y_n) = -\log p(y_n \mid z) and f(xn,θ0)=fθ0(xn,θ0)f(x_n, \theta_0) = f^{\theta_0}(x_n, \theta_0) using Equation (1), in the case when the Hessian of the negative log-likelihood loss ℓ\ell does not depend on the target yy, the GGN is equal to the FIM (up to a constant scaling factor):

G(θ0)=NF~(θ0).\ggn(\theta_0) = N\tilde{\fisher}(\theta_0).

In fact, the difference in the scaling factor has a natural interpretation. Previously, we saw that F(θ)\fisher(\theta) is the FIM of the random variable (X,Y)(\mathrm X, \mathrm Y) distributed according to p(x,y∣θ)p(x, y \mid \theta) and that the FIM is additive for independent random variables. Therefore, under this assumption, the GGN is equal to the FIM w.r.t. NN i.i.d. observations {(xn,yn)}n=1N\{(x_n, y_n)\}_{n=1}^N distributed as p(x,y∣θ)p(x, y \mid \theta) (and not as p(x,y)p(x, y)).

The requirement of the loss Hessian not depending on the target might seem arbitrary. However, this property is satisfied by a wide family of likelihoods, called exponential families.

First, we state some facts about simple parameterisations.

Parameterisations via neural networks are more delicate. The following proposition gives a necessary and sufficient condition for Equation (40).

The above statement on neural network parameterisations covers the most popular loss functions in classification and regression. In classification, the cross-entropy loss is the negative log-likelihood of a categorical distribution parameterised by our neural network. The logits are the categorical’s natural parameters, so with the identity link g=Id⁡g = \operatorname{Id} the cross-entropy loss satisfies Proposition 3 in its affine special case. Similarly, the L2L_2 loss for regression satisfies Proposition 3 with g=Id⁡g = \operatorname{Id}.

A word of caution is in order: the GGN/FIM alone is usually degenerate; thus, it does not serve as a valid precision matrix for the Laplace approximation. Considering a single input-label pair (xn,yn)(x_n, y_n), the term

(Jθf(xn,θ0))⊤(∇z∇z⊤ℓ(z,yn)∣z=fθ0(xn,θ0))Jθf(xn,θ0)\left(\jaclogit(x_n, \theta_0)\right)^{\top} \left(\nabla_{z}\nabla_{z}^{\top} \ell(z, y_n)\big|_{z = f^{\theta_0}(x_n, \theta_0)}\right) \jaclogit(x_n, \theta_0)

is a positive semidefinite (PSD) matrix, as the loss Hessian ∇z∇z⊤ℓ(z,yn)∣z=fθ0(xn,θ0)\nabla_{z}\nabla_{z}^{\top} \ell(z, y_n)\big|_{z = f^{\theta_0}(x_n, \theta_0)} is positive semidefinite. For softmax cross-entropy, this Hessian is diag⁡(p)−pp⊤\operatorname{diag}(p)-pp^{\top}, which is rank deficient as the softmax is shift-invariant. Usually, the GGN, that is, the sum of these matrices over the training dataset, is still rank deficient. However, adding the Hessian of the strongly convex regulariser term Ω(θ0)\Omega(\theta_0) to the GGN results in the positive definite matrix

Ψ(θ0)=∇θ∇θ⊤LΩθ0(θ0)=∇θ∇θ⊤Lθ0(θ0)+∇θ∇θ⊤Ω(θ0),\precision(\theta_0) = \nabla_\theta \nabla_\theta^{\top} \regrisk^{\theta_0}(\theta_0) = \nabla_\theta \nabla_\theta^{\top} \mathcal{L}^{\theta_0}(\theta_0) + \nabla_\theta\nabla_\theta^{\top} \Omega(\theta_0),

which is the Hessian of the regularised empirical risk of the linearised model, LΩθ0(θ0)\regrisk^{\theta_0}(\theta_0). This justifies using this matrix as a parameter-space precision in the Laplace approximation (Equation (6)).

With the curvature Ψ\precision in hand, we can place the NTK of Section The Prior and the posterior GP kernel of Equation (14) in a single frame. Both are Jacobian Gram matrices JθfM−1Jθf⊤\jaclogit M^{-1}\jaclogit^{\top} in a parameter-space metric MM; they differ in the expansion point (θ0\theta_0 for the NTK, θ∗\theta_* for the posterior kernel) and in the metric MM. Preconditioning the gradient flow of Equation (19) by MM multiplies the parameter velocity by M−1M^{-1}, inserting M−1M^{-1} between the Jacobians and replacing its kernel ktk_t with Jθf(x,θt)M−1Jθf(xn,θt)⊤\jaclogit(x,\theta_t)M^{-1}\jaclogit(x_n,\theta_t)^{\top}, holding the expansion point fixed and changing only the metric. Vanilla gradient descent uses the Euclidean metric M=IM=I and recovers the NTK, the isotropic-prior pushforward. Regularised natural-gradient descent Amari, 1998 uses M=Ψ(θt)M=\precision(\theta_t), the GGN/Fisher curvature plus the prior precision (Equation (43)) at the current parameters. We call the resulting kernel Jθf(⋅,θt)Ψ(θt)−1Jθf(⋅,θt)⊤\jaclogit(\cdot,\theta_t)\precision(\theta_t)^{-1}\jaclogit(\cdot,\theta_t)^{\top} the natural-gradient NTK. Because Ψ(θt)\precision(\theta_t) is positive definite at every θt\theta_t, the natural-gradient NTK governs the dynamics all along training, even where the gradient is nonzero and no Laplace posterior exists. It coincides with the posterior GP kernel JθfΨ−1Jθf⊤\jaclogit\precision^{-1}\jaclogit^{\top} Immer et al., 2021 only at a posterior mode θ∗\theta_*, as the Laplace approximation requires. The parameter-space metric thus determines both the predictive uncertainty, through the Gaussian we push forward, and the optimisation geometry, through the descent the function follows.

Scalable Curvature Approximations

The GGN of the linearised network (cf. Equation (22))

G(θ)=∑n=1N(Jθf(xn,θ))⊤∇z∇z⊤ℓ(z,yn)∣z=f(xn,θ)⏟=:Hn⪰0Jθf(xn,θ)∈RP×P\ggn(\theta) =\sum_{n=1}^{N} \left(\jaclogit(x_n,\theta)\right)^{\top} \underbrace{\nabla_{z}\nabla_{z}^{\top}\ell\left(z,y_n\right)\big|_{z=f(x_n,\theta)}}_{=:H_n\succeq 0} \jaclogit(x_n,\theta) \in\mathbb{R}^{P\times P}

is dense in general and far too large to form for modern neural networks. We therefore seek structured surrogates that (i) are cheap to store and invert, yet (ii) retain meaningful parameter correlations. Table 1 compares the three curvature proxies we develop: the diagonal, low-rank, and Kronecker-Factored Approximate Curvature (KFAC) approximations. Scalable variants of these curvature approximations are developed further in Chapter Scalable Laplace approximations, and last-layer inference is treated in Chapter Last-layer inference.

A simple baseline is the diagonal diag⁡G(θ)\operatorname{diag} \ggn(\theta), which is trivial to store and invert, though calculating it efficiently requires care. However, it encodes an independence assumption between all parameters, destroying the often-crucial within-layer correlations carried by G(θ)\ggn(\theta). This tends to hurt the utility of the downstream uncertainty estimates Daxberger et al., 2021.

Table 1:Common scalable curvature approximations for linearised Laplace. Here di−1d_{i-1} and did_i are the input and pre-activation dimensions of layer ii.

Approx.StorageCov.-vec.InversionCorrelationsBlind spot
Diag.O(P)\mathcal O(P)Elementwise divisionElementwiseNone across parametersMisses coupled directions
Low-rankO(kP)\mathcal O(k P)Products with Q1:kQ_{1:k}WoodburyTop eigenspace of G\ggnMisses broad low-curvature directions
KFAC∑iO(di−12+di2)\sum_i \mathcal O(d_{i-1}^2+d_i^2)Kronecker identitiesFactor eigensystemsWithin-layer KroneckerDrops cross-layer couplings

Low-rank GGN Approximations

A scalable yet expressive alternative is a low-rank approximation of G(θ)\ggn(\theta). As G(θ)\ggn(\theta) is symmetric for any θ∈RP\theta \in \mathbb{R}^P, it possesses an eigendecomposition with real eigenvalues of the form

G(θ)=Q(θ)Λ(θ)Q(θ)⊤,\ggn(\theta) = Q(\theta) \Lambda(\theta) Q(\theta)^{\top},

where Q(θ)∈RP×PQ(\theta) \in \mathbb{R}^{P \times P} is an orthogonal matrix (i.e., a matrix with orthonormal columns/rows) and Λ(θ)∈RP×P\Lambda(\theta) \in \mathbb{R}^{P \times P} is a diagonal matrix.

For q:,iq_{:,i}, the iith column of Q(θ)Q(\theta), and λi\lambda_i, the iith diagonal entry of Λ(θ)\Lambda(\theta), it holds that G(θ)q:,i=λiq:,i\ggn(\theta) q_{:, i} = \lambda_i q_{:, i}. We follow the convention λ1≥λ2≥⋯≥λP\lambda_1 \ge \lambda_2 \ge \cdots \ge \lambda_{P}. In the following, we drop the dependence of QQ and its factors on θ\theta for brevity.

We now seek a good low-rank approximation G~k\tilde{\ggn}_k to G\ggn, as this reduces the sizes of the objects we need to handle. Since G⪰0\ggn\succeq0, its eigenvalues are nonnegative, so the kk algebraically largest coincide with the kk largest in magnitude. The Eckart–Young–Mirsky theorem Eckart & Young, 1936 states that the objective

arg min⁡G′∈RP×P:rank⁡(G′)≤k∥G−G′∥\operatorname*{arg\,min}_{\ggn' \in \mathbb{R}^{P \times P}: \operatorname{rank}(\ggn') \le k} \Vert \ggn - \ggn' \Vert

is minimised by G~k:=Q1:kΛ1:kQ1:k⊤\tilde{\ggn}_k := Q_{1:k} \Lambda_{1:k} Q_{1:k}^{\top} where Q1:k∈RP×kQ_{1:k} \in \mathbb{R}^{P \times k} is the first kk columns of QQ and Λ1:k∈Rk×k\Lambda_{1:k} \in \mathbb{R}^{k \times k} holds the first kk eigenvalues of G\ggn. This result holds for both the spectral norm ∥ ⋅ ∥2\Vert~\cdot~\Vert_2 and the Frobenius norm ∥ ⋅ ∥F\Vert~\cdot~\Vert_F. Therefore, one obtains an optimal low-rank approximation G~k\tilde{\ggn}_k to G\ggn in the above sense by computing the first kk eigenvalues and eigenvectors of G\ggn. Storing this low-rank approximation requires storing (P+1)k(P + 1) k values instead of P2P^2.

The most naive way to compute G~k\tilde{\ggn}_k is first calculating the eigendecomposition G=QΛQ⊤\ggn = Q \Lambda Q^{\top} and then truncating it to the first kk eigenpairs. However, this strategy does not resolve the infeasibility of storing the full eigendecomposition with P(P+1)P(P + 1) values. Instead, one uses efficient matrix-free schemes such as the Locally Optimal Block Preconditioned Conjugate Gradient (LOBPCG) method Knyazev, 2001 or Lanczos iterations Lanczos, 1950 to obtain the low-rank decomposition. Notably, these algorithms only require matrix-vector products v↦Gvv \mapsto \ggn v with the GGN to obtain the top eigenpairs, which does not require representing the entire G\ggn matrix in memory.

The low-rank representation is particularly handy, as for simple priors, such as isotropic Gaussians, calculating the approximate covariance matrix is just as efficient as working with the low-rank GGN. Let Γ≻0\Gamma\succ0 be the Hessian of the negative log-prior Ω\Omega, that is, the prior-curvature term ∇θ∇θ⊤Ω\nabla_\theta\nabla_\theta^{\top}\Omega of the precision Ψ=G+∇θ∇θ⊤Ω\precision=\ggn+\nabla_\theta\nabla_\theta^{\top}\Omega (Equation (43)). Then the Woodbury matrix identity yields

(Γ+G~k)−1=Γ−1−Γ−1Q1:k(Λ1:k−1+Q1:k⊤Γ−1Q1:k)−1Q1:k⊤Γ−1.\left(\Gamma + \tilde{\ggn}_k\right)^{-1} = \Gamma^{-1} - \Gamma^{-1}Q_{1:k}\left(\Lambda_{1:k}^{-1}+Q_{1:k}^{\top} \Gamma^{-1}Q_{1:k}\right)^{-1}Q_{1:k}^{\top} \Gamma^{-1}.

In particular, for isotropic Gaussians, Γ=τI\Gamma=\tau I,

(τI+Q1:kΛ1:kQ1:k⊤)−1=τ−1I+Q1:kdiag⁡(−λ1τ(λ1+τ),…,−λkτ(λk+τ))Q1:k⊤.\left(\tau I + Q_{1:k}\Lambda_{1:k}Q_{1:k}^{\top}\right)^{-1} = \tau^{-1} I + Q_{1:k}\operatorname{diag}\left( -\frac{\lambda_1}{\tau(\lambda_1+\tau)},\ldots,-\frac{\lambda_k}{\tau(\lambda_k+\tau)} \right)Q_{1:k}^{\top}.

In words: a diagonal-plus-low-rank matrix has a diagonal-plus-low-rank inverse. Multiplying by such a matrix is efficient and does not require forming a P×PP \times P matrix. For a vector v∈RPv \in \mathbb{R}^{P}, we first calculate u=Q1:k⊤v∈Rku=Q_{1:k}^{\top} v \in \mathbb{R}^k, then elementwise multiply uu by the diagonal entries in diag⁡(−λ1τ(λ1+τ),…,−λkτ(λk+τ))\operatorname{diag}\left( -\frac{\lambda_1}{\tau(\lambda_1+\tau)},\ldots,-\frac{\lambda_k}{\tau(\lambda_k+\tau)} \right), then map the result back to RP\mathbb{R}^{P} with Q1:kQ_{1:k} and add the diagonal term τ−1v\tau^{-1}v.

Kronecker-Factored Approximate Curvature

A complementary path towards scalable approximate curvature representations assumes independence between layers only, while retaining rich within-layer parameter correlations via a Kronecker factorisation. This idea underlies KFAC, which has recently seen wide use as a scalable curvature proxy Martens & Grosse, 2015. In this section, we give an introduction to KFAC for dense linear layers and refer to Dangel et al. (2025) for a more detailed and general exposition of KFAC.

Consider layer ii with weights W(i)∈Rdi×di−1W^{(i)}\in\mathbb{R}^{d_i\times d_{i-1}}, input activation an(i−1)∈Rdi−1a_n^{(i-1)}\in\mathbb{R}^{d_{i-1}}, and pre-activation sn(i)=W(i)an(i−1)∈Rdis_n^{(i)}=W^{(i)}a_n^{(i-1)}\in\mathbb{R}^{d_i}.[4] Let zn=f(xn,θ)∈RCz_n=f(x_n,\theta)\in\mathbb{R}^{C} denote the network output. Let JW(i)sn(i)∈Rdi×(didi−1)J_{W^{(i)}} s_n^{(i)} \in \mathbb{R}^{d_i \times (d_i d_{i-1})} denote the Jacobian of sn(i)s_n^{(i)} w.r.t. vec⁡(W(i))\operatorname{vec}(W^{(i)}), where vec⁡\operatorname{vec} flattens its input by stacking its columns. For datum nn, define the output-space curvature Hn:=∇z∇z⊤ℓ(z,yn)∣z=zn⪰0H_n:=\nabla_{z}\nabla_{z}^{\top}\ell(z,y_n)\big|_{z=z_n}\succeq0, so Hn∈RC×CH_n\in\mathbb{R}^{C \times C}. Writing Hn=SnSn⊤H_n=S_nS_n^{\top} with Sn∈RC×CS_n\in\mathbb{R}^{C \times C}, the corresponding layer block of the GGN can be expressed as

G(i)=∑n=1N(JW(i)sn(i))⊤(Jsn(i)zn)⊤Hn(Jsn(i)zn)⏟=: H^n(i)⪰0JW(i)sn(i)=∑n=1N∑c=1C(JW(i)sn(i))⊤gn,c(i)(gn,c(i))⊤JW(i)sn(i).\begin{align} \ggn^{(i)} &= \sum_{n=1}^{N} (J_{W^{(i)}} s_n^{(i)})^{\top} \underbrace{(J_{s_n^{(i)}} z_n)^{\top} H_n(J_{s_n^{(i)}} z_n)}_{=:~\widehat H_{n}^{(i)}\succeq0} J_{W^{(i)}} s_n^{(i)} \notag\\ &= \sum_{n=1}^{N}\sum_{c=1}^{C} (J_{W^{(i)}} s_n^{(i)})^{\top} g_{n,c}^{(i)}(g_{n,c}^{(i)})^{\top} J_{W^{(i)}} s_n^{(i)}. \end{align}

with gn,c(i):=(Jsn(i)zn)⊤[Sn]:,c∈Rdig_{n,c}^{(i)}:=(J_{s_n^{(i)}} z_n)^{\top}[S_n]_{:,c}\in\mathbb{R}^{d_i}, where Jsn(i)znJ_{s_n^{(i)}} z_n is the Jacobian of the network output znz_n w.r.t. this layer’s pre-activation sn(i)s_n^{(i)}.[5] Thus, the sum over cc is over the network output curvature factor, while gn,c(i)g_{n,c}^{(i)} lives in the layer pre-activation space.

For a linear layer, the output-parameter Jacobian has the form JW(i)sn(i)=(an(i−1))⊤⊗IdiJ_{W^{(i)}} s_n^{(i)} = (a_n^{(i-1)})^{\top} \otimes I_{d_i} where ⊗\otimes denotes the Kronecker product. Noting the Kronecker properties (A⊗B)⊤=A⊤⊗B⊤(A \otimes B)^{\top} = A^{\top} \otimes B^{\top} and (A⊗B)(C⊗D)=(AC)⊗(BD)(A \otimes B) (C \otimes D) = (AC) \otimes (BD) for compatible matrices A,B,C,DA, B, C, D, we get

G(i)=∑n=1N∑c=1C(an(i−1)(an(i−1))⊤)⏟input factor⊗(gn,c(i)(gn,c(i))⊤)⏟backpropagated factor∈R(di−1di)×(di−1di).\begin{align} \ggn^{(i)} =\sum_{n=1}^{N}\sum_{c=1}^{C} \underbrace{(a_n^{(i-1)} (a_n^{(i-1)})^{\top})}_{\text{input factor}} \otimes \underbrace{(g_{n,c}^{(i)}(g_{n,c}^{(i)})^{\top})}_{\text{backpropagated factor}} \in\mathbb{R}^{(d_{i-1}d_i)\times(d_{i-1}d_i)}. \end{align}

The KFAC approximation then pulls the Kronecker product outside the sum:

∑n=1N∑c=1C(an(i−1)(an(i−1))⊤)⊗(gn,c(i)(gn,c(i))⊤)≈(∑n=1Nan(i−1)(an(i−1))⊤)⏟=: A(i)⊗(1N∑n=1N∑c=1Cgn,c(i)(gn,c(i))⊤)⏟=: B(i).\begin{align} &\sum_{n=1}^{N}\sum_{c=1}^{C} \left(a_n^{(i-1)} (a_n^{(i-1)})^{\top}\right)\otimes\left(g_{n,c}^{(i)}(g_{n,c}^{(i)})^{\top}\right) \notag\\ &\approx \underbrace{\left(\sum_{n=1}^{N}a_n^{(i-1)} (a_n^{(i-1)})^{\top}\right)}_{=:~A^{(i)}} \otimes \underbrace{\left(\frac{1}{N}\sum_{n=1}^{N}\sum_{c=1}^{C}g_{n,c}^{(i)}(g_{n,c}^{(i)})^{\top}\right)}_{=:~B^{(i)}}. \end{align}

Thus, the layer block is approximated by

G(i)≈A(i)⊗B(i)=:G~(i),A(i)∈Rdi−1×di−1,B(i)∈Rdi×di.\ggn^{(i)}\approx A^{(i)}\otimes B^{(i)} =: \tilde{\ggn}^{(i)}, \qquad A^{(i)}\in\mathbb{R}^{d_{i-1}\times d_{i-1}}, B^{(i)}\in\mathbb{R}^{d_i\times d_i}.

Stacking layers and neglecting inter-layer couplings yields a block-diagonal curvature with Kronecker blocks A(i)⊗B(i)A^{(i)}\otimes B^{(i)}.

The Kronecker form is efficient to store. While the dense GGN G(i)\ggn^{(i)} for a single linear layer has (di−1di)2(d_{i-1}d_i)^2 entries, the Kronecker factorisation only requires storing A(i)A^{(i)} and B(i)B^{(i)}, that is, a total of di−12+di2d_{i-1}^2+d_i^2 values. The block-diagonal layer approximation then avoids storing cross-layer blocks. One can also calculate efficient covariance-vector products without forming a dense P×PP \times P matrix by leveraging the cached eigendecompositions of the Kronecker factors and standard Kronecker identities. This property is more involved to show than in the case of low-rank approximations; refer to Dangel et al. (2025) for more details.

The Predictive

Equation (13) gives a Gaussian distribution in the output space for input x∗x_*. For regression, this distribution is called the predictive distribution: its mean encodes the average prediction under the parameter-space posterior and the linearised model, and its covariance structure quantifies the uncertainty in the prediction, including correlations of the outputs. Figure 3 shows a one-dimensional regression example of the linearised Laplace approximation.

A one-dimensional regression example with irregular inputs and input-dependent observation noise. The model is a neural network with a Bayesian last layer, so the linearisation is exact and the linearised GP yields the exact posterior predictive. The shaded region shows the pointwise 95\% latent GP interval, while the dashed curves add the input-dependent observation variance.

Figure 3:A one-dimensional regression example with irregular inputs and input-dependent observation noise. The model is a neural network with a Bayesian last layer, so the linearisation is exact and the linearised GP yields the exact posterior predictive. The shaded region shows the pointwise 95%95\% latent GP interval, while the dashed curves add the input-dependent observation variance.

In classification, however, we are interested in obtaining a second-order distribution (a distribution over distributions) over the categorical distributions of a discrete set of labels. To this end, one has to map the logit-space Gaussian measure in Equation (13) through an activation function onto the (C−1C - 1)-dimensional probability simplex:

h ⁣:RD→fG(RC)→φ∗P(ΔC−1)\mathrm h\colon \mathbb{R}^{D} \xrightarrow{\quad \mathrm{f} \quad} \mathcal G\left(\mathbb{R}^{C}\right) \xrightarrow{\varphi_*} \mathcal P\left(\Delta^{C-1}\right)

where f\mathrm f is the mapping from an input x∗x_* to the logit-space Gaussian distribution given by the Laplace-approximated network, G(RC)\mathcal G(\mathbb{R}^{C}) is the set of Gaussian measures on the logit space RC\mathbb{R}^{C}, P(ΔC−1)\mathcal P\left(\Delta^{C-1}\right) is the set of probability measures on the simplex, and φ∗\varphi_* pushes forward the Gaussian probability measures through the activation function. The roman f\mathrm{f} is the network with its parameter posterior pushed through it: the affine pushforward of the Laplace posterior N(θ;θ∗,Ψ(θ∗)−1)\mathcal{N}(\theta;\theta_*,\precision(\theta_*)^{-1}) along the linearised network, giving f(x∗)=N(f(x∗,θ∗),Jθf(x∗,θ∗)Ψ(θ∗)−1Jθf(x∗,θ∗)⊤)∈G(RC)\mathrm{f}(x_*)=\mathcal{N}(f(x_*,\theta_*), \jaclogit(x_*,\theta_*)\precision(\theta_*)^{-1}\jaclogit(x_*,\theta_*)^{\top})\in\mathcal G(\mathbb{R}^{C}) as in Equation (13). The italic f(x∗,θ∗)∈RCf(x_*,\theta_*)\in\mathbb{R}^{C} plugs in the point estimate θ∗\theta_* and returns a single logit vector; the roman f(x∗)\mathrm{f}(x_*) returns the full logit-space Gaussian, whose mean is exactly that italic vector. All parameters in the support of the Laplace posterior are taken into account rather than a single one being held fixed, so f\mathrm{f} takes only the input. In words, h\mathrm h is the composition of the Laplace-approximated neural network outputting logit-space Gaussian distributions, f\mathrm{f}, and the pushforward map through the activation function that gives us a distribution over probability vectors.

In most cases, this activation function is the softmax, defined as softmax⁡ ⁣:RC→ΔC−1\operatorname{softmax}\colon \mathbb{R}^{C} \to \Delta^{C - 1},

softmax⁡c(z)=exp⁡(zc)∑c′=1Cexp⁡(zc′).\operatorname{softmax}_c(z) = \frac{\exp(z_c)}{\sum_{c'=1}^C \exp(z_{c'})}.

In this case, there exists no closed-form expression for h(x∗)∈P(ΔC−1)\mathrm h(x_*) \in \mathcal{P}\left(\Delta^{C - 1}\right) given input x∗x_*. Further, EP∼h(x∗)[P]\mathbb{E}_{P \sim \mathrm h(x_*)}\left[P\right], called the posterior predictive, is also intractable. However, sampling from h(x∗)\mathrm h(x_*) is efficient, as it only requires sampling from the logit-space Gaussian f(x∗)\mathrm{f}(x_*) and pushing these logit samples forward through the activation function. Thus, in practice, one resorts to Monte Carlo integration, that is, drawing MM samples from h(x∗)\mathrm h(x_*) and calculating their empirical average. Similarly, one can approximate other derived quantities, such as the expected entropy EP∼h(x∗)[H⁡(P)]\mathbb{E}_{P \sim \mathrm h(x_*)}\left[\ShanEntSymb(P)\right], through Monte Carlo sampling. Such derived quantities are often used in the field of uncertainty disentanglement, where different quantities capture different sources of uncertainty Mucsányi et al., 2024. These uncertainty estimates are applied to selective classification in Chapter Confidence-based selective classification.

The main issue with the above schemes is the requirement of sampling: the error of Monte Carlo integration decreases as the inverse square root of the number of samples MM, meaning that to reduce the error by three orders of magnitude, one needs a million samples. Standard softmax-cross-entropy integration cannot avoid this sampling cost without incurring significant approximation error. However, some output activation functions admit a closed-form posterior predictive. For a single output, integrating a normCDF (probit) link against a Gaussian is exact, and the logistic sigmoid admits a classical probit approximation MacKay, 1992. Mucsányi et al. (2025) show that the normalised elementwise sigmoid and normCDF functions yield closed-form predictives that have strong approximation guarantees and are naturally compatible with more performant training objectives than the standard softmax-cross-entropy objective. Further, derived quantities such as the expected entropy can also be obtained in closed form by matching the moments of the Gaussian pushforward distributions with Dirichlets. The change in the training objective comes at no cost: models trained this way become better calibrated while providing sample-free posterior predictives and other derived quantities. Therefore, Laplace approximations in classification can be formulated in a purely sample-free fashion, with theoretical guarantees. Figure 4 compares the MAP, Monte Carlo softmax, and sample-free probit predictives on a two-dimensional example, together with the predictive entropy.

Two-dimensional binary classification with a Laplace approximation to the last layer of a fixed-feature network on the Iris dataset. The inputs are the measured sepal width and petal width. White denotes Iris versicolor and black denotes Iris virginica. Circles are training points, triangles are validation points, and squares are test points. The prior precision is selected on the validation set by log score. Panels (a)–(c) show the probability of the black class for the MAP predictor, the softmax posterior predictive estimated by Monte Carlo sampling, and the sample-free probit approximation. Panel (d) shows the predictive entropy computed from the Monte Carlo predictive. On the held-out test points, the MAP log score and Brier score are 0.433 and 0.122, while the Monte Carlo GP predictive gives 0.345 and 0.107, and the probit predictive gives 0.347 and 0.108—close to indistinguishable.

(a)

Two-dimensional binary classification with a Laplace approximation to the last layer of a fixed-feature network on the Iris dataset. The inputs are the measured sepal width and petal width. White denotes Iris versicolor and black denotes Iris virginica. Circles are training points, triangles are validation points, and squares are test points. The prior precision is selected on the validation set by log score. Panels (a)–(c) show the probability of the black class for the MAP predictor, the softmax posterior predictive estimated by Monte Carlo sampling, and the sample-free probit approximation. Panel (d) shows the predictive entropy computed from the Monte Carlo predictive. On the held-out test points, the MAP log score and Brier score are 0.433 and 0.122, while the Monte Carlo GP predictive gives 0.345 and 0.107, and the probit predictive gives 0.347 and 0.108—close to indistinguishable.

(b)

Two-dimensional binary classification with a Laplace approximation to the last layer of a fixed-feature network on the Iris dataset. The inputs are the measured sepal width and petal width. White denotes Iris versicolor and black denotes Iris virginica. Circles are training points, triangles are validation points, and squares are test points. The prior precision is selected on the validation set by log score. Panels (a)–(c) show the probability of the black class for the MAP predictor, the softmax posterior predictive estimated by Monte Carlo sampling, and the sample-free probit approximation. Panel (d) shows the predictive entropy computed from the Monte Carlo predictive. On the held-out test points, the MAP log score and Brier score are 0.433 and 0.122, while the Monte Carlo GP predictive gives 0.345 and 0.107, and the probit predictive gives 0.347 and 0.108—close to indistinguishable.

(c)

Two-dimensional binary classification with a Laplace approximation to the last layer of a fixed-feature network on the Iris dataset. The inputs are the measured sepal width and petal width. White denotes Iris versicolor and black denotes Iris virginica. Circles are training points, triangles are validation points, and squares are test points. The prior precision is selected on the validation set by log score. Panels (a)–(c) show the probability of the black class for the MAP predictor, the softmax posterior predictive estimated by Monte Carlo sampling, and the sample-free probit approximation. Panel (d) shows the predictive entropy computed from the Monte Carlo predictive. On the held-out test points, the MAP log score and Brier score are 0.433 and 0.122, while the Monte Carlo GP predictive gives 0.345 and 0.107, and the probit predictive gives 0.347 and 0.108—close to indistinguishable.

(d)

Figure 4:Two-dimensional binary classification with a Laplace approximation to the last layer of a fixed-feature network on the Iris dataset. The inputs are the measured sepal width and petal width. White denotes Iris versicolor and black denotes Iris virginica. Circles are training points, triangles are validation points, and squares are test points. The prior precision is selected on the validation set by log score. Panels (a)–(c) show the probability of the black class for the MAP predictor, the softmax posterior predictive estimated by Monte Carlo sampling, and the sample-free probit approximation. Panel (d) shows the predictive entropy computed from the Monte Carlo predictive. On the held-out test points, the MAP log score and Brier score are 0.433 and 0.122, while the Monte Carlo GP predictive gives 0.345 and 0.107, and the probit predictive gives 0.347 and 0.108—close to indistinguishable.

Footnotes
  1. Note that this network is only linear in its parameters θ\theta but is still nonlinear in its inputs xx.

  2. In particular, the transition from Equation (5) to Equation (6) is not justified when Ψ(θ∗)\precision(\theta_*) is not positive definite.

  3. For a finite-width network, this is sometimes called the empirical NTK at θ0\theta_0, and the NTK is reserved for networks in the infinite-width limit.

  4. Bias terms are omitted for brevity.

  5. For the squared loss, Hn=IH_n=I; for cross-entropy, Hn=diag⁡(softmax⁡(z))−softmax⁡(z)softmax⁡(z)⊤H_n = \operatorname{diag}(\operatorname{softmax}(z)) - \operatorname{softmax}(z)\operatorname{softmax}(z)^{\top} is the softmax Hessian.

References
  1. MacKay, D. J. C. (1992). A Practical Bayesian Framework for Backpropagation Networks. Neural Computation, 4(3), 448–472.
  2. Ritter, H., Botev, A., & Barber, D. (2018). A Scalable Laplace Approximation for Neural Networks. 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings.
  3. Lawrence, N. D. (2000). Variational Inference in Probabilistic Models [Ph.D. thesis]. Department of Computer Science.
  4. Immer, A., Korzepa, M., & Bauer, M. (2021). Improving predictions of Bayesian neural nets via local linearization. In A. Banerjee & K. Fukumizu (Eds.), Proceedings of The 24th International Conference on Artificial Intelligence and Statistics (Vol. 130, pp. 703–711). PMLR.
  5. Jacot, A., Gabriel, F., & Hongler, C. (2018). Neural Tangent Kernel: Convergence and Generalization in Neural Networks. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, & R. Garnett (Eds.), Advances in Neural Information Processing Systems (Vol. 31). Curran Associates, Inc.
  6. Cinquin, T., Pförtner, M., Fortuin, V., Hennig, P., & Bamler, R. (2024). FSP-Laplace: Function-Space Priors for the Laplace Approximation in Bayesian Deep Learning. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, & C. Zhang (Eds.), Advances in Neural Information Processing Systems (Vol. 37, pp. 13897–13926). Curran Associates, Inc.
  7. Kunstner, F., Hennig, P., & Balles, L. (2019). Limitations of the empirical Fisher approximation for natural gradient descent. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d’Alché Buc, E. Fox, & R. Garnett (Eds.), Advances in Neural Information Processing Systems (Vol. 32). Curran Associates, Inc.
  8. Amari, S. (1998). Natural Gradient Works Efficiently in Learning. Neural Computation, 10(2), 251–276.
  9. Daxberger, E., Kristiadi, A., Immer, A., Eschenhagen, R., Bauer, M., & Hennig, P. (2021). Laplace Redux - Effortless Bayesian Deep Learning. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P. S. Liang, & J. W. Vaughan (Eds.), Advances in Neural Information Processing Systems (Vol. 34, pp. 20089–20103). Curran Associates, Inc.
  10. Eckart, C., & Young, G. (1936). The Approximation of One Matrix by Another of Lower Rank. Psychometrika, 1(3), 211–218.
  11. Knyazev, A. V. (2001). Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method. SIAM Journal on Scientific Computing, 23(2), 517–541.
  12. Lanczos, C. (1950). An iteration method for the solution of the eigenvalue problem of linear differential and integral operators. Journal of Research of the National Bureau of Standards, 45(4), 255–282.
  13. Martens, J., & Grosse, R. (2015). Optimizing Neural Networks with Kronecker-factored Approximate Curvature. In F. Bach & D. Blei (Eds.), Proceedings of the 32nd International Conference on Machine Learning (Vol. 37, pp. 2408–2417). PMLR.
  14. Dangel, F., Mucsányi, B., Weber, T., & Eschenhagen, R. (2025). Kronecker-factored Approximate Curvature (KFAC) From Scratch.
  15. Mucsányi, B., Kirchhof, M., & Oh, S. J. (2024). Benchmarking Uncertainty Disentanglement: Specialized Uncertainties for Specialized Tasks. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, & C. Zhang (Eds.), Advances in Neural Information Processing Systems (Vol. 37, pp. 50972–51038). Curran Associates, Inc.