The Laplace approximation is a method that replaces an intractable probability distribution, usually a Bayesian posterior, with a Gaussian centered at the distribution’s mode, whose covariance is the inverse of the negative Hessian of the log density at that point. Probabilistic models in machine learning use it to obtain fast uncertainty estimates and an approximation of the marginal likelihood without sampling.
The technique goes back to Pierre-Simon Laplace’s work on integrals in the late eighteenth century. In modern artificial intelligence it is valued because it reuses an optimization result: once a maximum a posteriori estimate is found, only second-order curvature information is needed to turn a point estimate into a full approximate posterior.
How the Laplace approximation is constructed
The Laplace approximation is constructed by a second-order Taylor expansion of the log posterior around its mode. Because the gradient is zero at the mode, the expansion contains only a constant and a quadratic term, and the exponential of a quadratic is a Gaussian density.
- Find the mode by maximizing the log joint density, which yields the maximum a posteriori estimate.
- Compute the Hessian matrix of the negative log posterior at that mode.
- Use the mode as the mean and the inverse Hessian as the covariance.
- Optionally evaluate the evidence approximation from the same quantities.
The evidence approximation follows directly: the log marginal likelihood is approximated by the log joint density at the mode, plus half of the dimension times the log of two pi, minus half of the log determinant of the Hessian. This term acts as an automatic Occam factor that penalizes models whose posterior is sharply peaked relative to the prior.
The table lists the core quantities and the role each one plays in the approximation.
| Quantity | How it is obtained | Role in the approximation |
|---|---|---|
| Mode | Gradient-based optimization | Mean of the Gaussian |
| Hessian | Second derivatives of the negative log posterior | Precision matrix |
| Covariance | Inverse of the Hessian | Uncertainty in parameters |
| Log determinant | From the Hessian factorization | Volume term in the evidence |
Hessian approximations and scalable variants
Scalable variants of the Laplace approximation exist because the exact Hessian is too expensive for models with millions of parameters. Storing a full matrix grows quadratically with the parameter count, and inverting it grows cubically, so practitioners trade fidelity for tractability.
| Variant | Curvature structure | Typical use |
|---|---|---|
| Full Hessian | Dense matrix | Small models, logistic regression |
| Diagonal | Per-parameter variance only | Large networks with tight budgets |
| Kronecker-factored (KFAC) | Per-layer Kronecker products | Deep neural networks |
| Generalized Gauss-Newton | Positive semidefinite approximation | Stable curvature in deep learning |
| Last-layer Laplace | Full curvature on final layer only | Cheap uncertainty for pretrained models |
In a Bayesian neural network, the generalized Gauss-Newton matrix is often preferred because the true Hessian can be indefinite away from an exact optimum, which would produce an invalid covariance. A prior precision term is added to the curvature, and tuning that term by maximizing the approximate evidence is a standard step.
Laplace approximation compared with other inference methods
Compared with other approximate inference methods, the Laplace approximation is the cheapest and the most local. It describes the posterior only through the shape of one peak, whereas sampling and optimization-based methods can capture more of the global structure.
| Method | Approximation type | Main strength | Main weakness |
|---|---|---|---|
| Laplace approximation | Gaussian at the mode | Post hoc and fast | Ignores skew and other modes |
| Variational inference | Optimized family member | Scales with stochastic gradients | Underestimates variance |
| Markov chain Monte Carlo | Samples from the posterior | Asymptotically exact | Slow on large models |
| Expectation propagation | Moment matching per factor | Accurate marginals | Convergence not guaranteed |
Variational inference optimizes the evidence lower bound and therefore chooses its Gaussian globally, while the Laplace approximation fixes its Gaussian locally from curvature. For Gaussian process classification, the Laplace approximation was historically a standard choice because the posterior over latent function values is unimodal and log-concave under common likelihoods.
When the approximation works and when it fails
The Laplace approximation works well when the posterior is unimodal, roughly symmetric and concentrated, which tends to happen as the amount of data grows. The Bernstein-von Mises theorem formalizes this: under regularity conditions, posteriors approach a Gaussian as the sample size increases.
- Multimodal posteriors: only one mode is described, so other plausible solutions are missed.
- Skewed or bounded parameters: variances and rates near zero produce poor Gaussian fits unless the parameter is reparameterized on the log scale.
- Small data: curvature at the mode may not represent the overall spread.
- Non-converged optimization: a Hessian taken away from the true mode can be indefinite.
- Overconfident predictions: in deep networks, naive sampling from the Gaussian can perform poorly, so the linearized predictive is often used instead.
The parameterization matters because the approximation is not invariant to reparameterization. Transforming constrained parameters to an unconstrained space before expanding usually improves accuracy substantially.
Practical use in modern machine learning
In modern machine learning, the Laplace approximation is used mainly for post hoc uncertainty quantification and model selection. Because it starts from a trained model, it can add calibrated predictive uncertainty to an existing network without retraining.
The decision table matches common goals with a suitable configuration.
| Goal | Recommended setup | Reason |
|---|---|---|
| Calibrate a pretrained classifier | Last-layer KFAC Laplace | Low cost with useful uncertainty |
| Compare model architectures | Evidence from full or KFAC curvature | Occam factor penalizes complexity |
| Hierarchical statistical model | Nested Laplace methods such as INLA | Accurate marginals for latent Gaussian models |
| Detect out-of-distribution inputs | Linearized predictive variance | Avoids overconfident softmax outputs |
Libraries for Laplace inference in deep learning typically expose the subset of weights, the Hessian structure and the prior precision as separate choices. A reliable workflow is to train normally, fit curvature on the training data, tune the prior precision on the evidence and then validate calibration on held-out data.
Understanding it simply
Imagine a hill that shows how likely each answer is. The top of the hill is the best single answer. The Laplace approximation looks only at that top. It measures how sharply the hill curves there.
A sharp peak means the model is confident. A wide, gentle peak means it is unsure. The method then draws a simple bell-shaped hill with the same top and the same curve. That bell shape is easy to work with. The catch is clear: if the real hill has two peaks or a lopsided shape, the bell shape misses part of the picture.
Applied in practice
A team building a medical image classifier already has a trained convolutional network with high accuracy on its validation set. Clinicians, however, need to know when the model is uncertain, so that doubtful scans go to a radiologist instead of being labeled automatically.
Retraining with sampling-based methods would take weeks. The team instead applies a last-layer Laplace approximation with Kronecker-factored curvature, tunes the prior precision by maximizing the approximate evidence and uses the linearized predictive distribution for each scan. The extra computation takes under an hour on one GPU.
On held-out data, the expected calibration error drops noticeably, and scans from an unfamiliar scanner receive higher predictive variance. The hospital sets a variance threshold that routes about one scan in ten for human review, which keeps automated decisions limited to cases where the model is genuinely confident.