Laplace Redux - Effortless Bayesian Deep Learning

Erik Daxberger, Agustinus Kristiadi, Alexander Immer, Runa Eschenhagen, Matthias Bauer, Philipp Hennig

TL;DR

This paper breathes new life into the Laplace Approximation (LA), a classic but often overlooked method for turning standard neural networks into Bayesian ones. By introducing the laplace library and demonstrating that LA is both computationally cheap and highly competitive with state-of-the-art methods, the authors show that robust uncertainty quantification doesn't have to be a finicky or expensive ordeal.

What Problem Does This Paper Address?

Modern deep learning models are notoriously "overconfident." They might predict a class with 99% certainty even when the input is complete noise or comes from a data distribution they’ve never seen before. Bayesian Neural Networks (BNNs) offer a solution by treating model weights as probability distributions rather than single points, allowing the model to express uncertainty and effectively say, "I don't know."

From MAP estimation to Laplace Approximation and Prediction

However, BNNs have a reputation for being a nightmare to implement. Popular methods like Variational Bayes (VB) often require changing the model architecture or training loop, while Monte Carlo (MCMC) methods are too slow for large-scale use. The Laplace Approximation—which simply fits a Gaussian distribution around a pre-trained model's "peak" (the MAP estimate)—is often dismissed as being too simple or too expensive due to the math involved in calculating the Hessian (the matrix of second derivatives). This paper sets out to prove those misconceptions wrong.

Methods

The authors break down the "scalable" Laplace Approximation into four modular components, which they have packaged into an easy-to-use PyTorch library called laplace. This library allows researchers to "Bayesian-ize" a pre-trained model with just a few lines of code.

The four modular components of the laplace library
  1. Weight Selection: You can apply LA to all weights, a specific subnetwork, or—most efficiently—just the last layer.
  2. Hessian Approximation: Since storing a full Hessian matrix for millions of parameters is impossible, they utilize approximations like Diagonal, Low-rank, or KFAC (Kronecker-factored approximate curvature).
  3. Hyperparameter Tuning: They demonstrate how to tune the "prior precision" (essentially the weight decay) using the marginal likelihood. This can be done either during training (online) or after the model is finished (post-hoc).
  4. Predictive Distribution: They provide various ways to turn the weight distribution into a final prediction, including Monte Carlo sampling and the probit approximation.

Key Insights and Results

The authors evaluated their approach across a wide range of tasks, including standard image classification (MNIST, CIFAR-10), realistic distribution shifts (WILDS benchmark), and continual learning (Permuted-MNIST).

  • The "Last-Layer" Powerhouse: One of the most striking insights is that applying the Laplace Approximation to only the last layer of a network is often enough to get excellent uncertainty estimates. This makes the computational cost almost negligible compared to standard training.
  • Post-hoc is Viable: You don't need to train a model from scratch to make it Bayesian. You can take a "vanilla" model off the shelf and apply LA to it afterward.
  • Debunking the "Old is Bad" Myth: LA actually outperforms more modern and complex methods like Variational Bayes in many Out-of-Distribution (OOD) detection tasks.
  • Calibration and Speed: On corrupted data, LA significantly reduced overconfidence compared to standard MAP training. Furthermore, LA is the cheapest Bayesian method tested, adding almost zero overhead compared to Deep Ensembles or SWAG.
  • Continual Learning: LA effectively prevented "catastrophic forgetting" on the Permuted-MNIST benchmark, maintaining ~96% accuracy across ten tasks, whereas standard models crashed to near-zero.

Limitations and Future Work

While the paper makes a strong case for LA, the authors note a few hurdles. The laplace library relies on external tools like BackPACK and ASDL for Hessian calculations; if these backends don't support a specific layer type (like certain exotic attention mechanisms), LA cannot be easily applied. Additionally, some advanced Hessian factorizations are not yet integrated, and marginal likelihood estimates for model selection can still be sensitive to the choice of Hessian approximation.

Ultimately, the authors argue that the Laplace Approximation should be the new baseline for Bayesian deep learning: it's fast, it's easy, and it works.

Summary updated

BibTeX
@inproceedings{daxberger2021laplace,
  author = {Erik Daxberger and Agustinus Kristiadi and Alexander Immer and Runa Eschenhagen and Matthias Bauer and Philipp Hennig},
  title = {{Laplace Redux - Effortless Bayesian Deep Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=tOk4Zl5FcA},
}
Figure