Expressive yet Tractable Bayesian Deep Learning via Subnetwork Inference

Erik A. Daxberger, Eric T. Nalisnick, James Urquhart Allingham, Javier Antorán, José Miguel Hernández-Lobato

Abstract

The Bayesian paradigm has the potential to solve core issues of deep neural networks such as poor calibration and data inefficiency. Alas, scaling Bayesian inference to large weight spaces often requires restrictive approximations. In this work, we show that it suffices to perform inference over a small subset of model weights in order to obtain accurate predictive posteriors. The other weights are kept as point estimates. This subnetwork inference framework enables us to use expressive, otherwise intractable, posterior approximations over such subsets. In particular, we implement subnetwork linearized Laplace as a simple, scalable Bayesian deep learning method: We first obtain a MAP estimate of all weights and then infer a full-covariance Gaussian posterior over a subnetwork using the linearized Laplace approximation. We propose a subnetwork selection strategy that aims to maximally preserve the model's predictive uncertainty. Empirically, our approach compares favorably to ensembles and less expressive posterior approximations over full networks.

Introduction

Deep neural networks (NNs) are notoriously overconfident, often failing to signal uncertainty when encountering out-of-distribution (OOD) data. Bayesian Neural Networks (BNNs) provide a principled framework for uncertainty quantification by treating weights as probability distributions. However, modern architectures with millions of parameters make full-covariance Bayesian inference computationally prohibitive. Standard workarounds, such as diagonal approximations, often fail to capture the critical weight correlations necessary for robust uncertainty estimates.

Subnetwork Inference Framework

The authors introduce subnetwork inference, a framework designed to make expressive Bayesian deep learning scalable. Instead of approximating the posterior over all weights, the method focuses on a small, carefully selected subset of weights while keeping the rest as point estimates.

The pipeline consists of four main stages:

  1. Point Estimation: A standard neural network is trained to find the Maximum A Posteriori (MAP) weights.
  2. Subnetwork Selection: A tiny fraction of weights (often <1%) is identified as critical for representing uncertainty.
  3. Bayesian Inference: Expressive, full-covariance inference—specifically the linearized Laplace approximation—is performed only on this subnetwork.
  4. Prediction: The resulting model, combining point estimates and a probabilistic subnetwork, is used for inference.
The subnetwork inference pipeline: from point estimation to subnetwork-based prediction.

A key innovation is the subnetwork selection strategy. The authors derive a method based on the Wasserstein distance to choose weights that minimize the discrepancy between the subnetwork posterior and the full-network posterior. In practice, this leads to selecting weights with the highest marginal variances.

Experimental Evaluation

The approach was tested across several benchmarks:

  • Synthetic 1D Regression: Visualizing "in-between" uncertainty.
  • UCI Tabular Regression: Testing performance on datasets like wine and protein, including "gap" variants for OOD testing.
  • Image Classification: Evaluating robustness on Rotated MNIST and Corrupted CIFAR-10 using ResNet architectures.
  • OOD Detection: Testing on "alien" data (e.g., CIFAR-10 vs. SVHN).

Key Results and Discussion

The central finding is that an expressive, correlated posterior over a few weights is superior to a simplistic, independent posterior over all weights. This "uncertainty pruning" allows the model to maintain accuracy while focusing its probabilistic "budget" on the most informative parameters.

On 1D regression tasks, a subnetwork using only 1% of weights (selected via the Wasserstein strategy) captured "in-between" uncertainty significantly better than a diagonal approximation using 100% of the weights.

Comparison of predictive distributions for 1D regression. Wasserstein-based selection (top) preserves uncertainty much better than random selection (bottom) as the subnetwork size shrinks.

In image classification under distribution shift, subnetwork inference consistently outperformed deep ensembles—the current industry standard—in terms of log-likelihood. Furthermore, the method is highly efficient; for a ResNet-18, restricting full-covariance modeling to ~40k weights reduces memory requirements from an impossible 500TB to a manageable 6.4GB.

Limitations and Future Outlook

While promising, the method has limitations. Computing Jacobians for the linearized Laplace approximation is computationally expensive for models with many outputs (e.g., semantic segmentation). Additionally, the performance is sensitive to prior precision tuning. Future work may explore "mixtures of Laplace" to capture the multi-modal nature of weight spaces, which the current unimodal Gaussian assumption cannot represent.

The subnetwork (linearized) Laplace method is implemented within the laplace PyTorch library.

Summary updated

BibTeX
@inproceedings{daxberger2021expressive,
  author = {Erik A. Daxberger and Eric T. Nalisnick and James Urquhart Allingham and Javier Antorán and José Miguel Hernández-Lobato},
  title = {{Expressive yet Tractable Bayesian Deep Learning via Subnetwork Inference}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=rCl-jqkdrgq},
}
Figure