Bayesian Deep Learning via Subnetwork Inference

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

TL;DR: Bayesian Deep Learning often forces a choice between scalability and expressiveness. This paper introduces a "subnetwork inference" framework that performs rich, full-covariance Bayesian inference on a tiny subset of important weights while keeping the rest fixed. This achieves state-of-the-art uncertainty quantification with a fraction of the memory overhead.

The Problem: Overconfidence and Scaling

Deep Neural Networks (NNs) are notoriously overconfident, often making high-certainty predictions even when input data is far outside their training distribution (e.g., an autonomous car misidentifying a novel obstacle). Bayesian Neural Networks (BNNs) address this by treating weights as probability distributions rather than fixed points, allowing the model to "know what it doesn't know."

However, exact Bayesian inference is computationally intractable for modern NNs with millions of parameters. To scale, researchers typically rely on approximations like Diagonal Laplace or Mean-Field Variational Inference, which assume every weight is independent. While computationally cheap, these methods fail to capture complex correlations between weights, leading to poor uncertainty estimates. The authors pose a critical question: Is it better to have a simple approximation of the whole network, or a sophisticated approximation of a small, critical part of it?

Subnetwork Inference Framework

To answer this, the authors propose a four-step framework for Subnetwork Inference:

The four-step subnetwork inference framework
  1. Point Estimation: Train a standard neural network to find the Maximum A Posteriori (MAP) weights (essentially, a standard pre-trained model).
  2. Subnetwork Selection: Identify a small subset of weights that are most critical for representing uncertainty. The authors derive a selection strategy based on the Wasserstein distance, which practically simplifies to choosing weights with the highest marginal variance (the ones the model is most "unsure" about).
  3. Bayesian Inference: Perform Linearized Laplace inference only on the selected subnetwork, using a full-covariance Gaussian posterior. While a full-covariance matrix for an entire ResNet-18 would require ~500 Terabytes of memory, a subnetwork of 40,000 weights fits into a highly manageable ~6.4 Gigabytes.
  4. Prediction: At test time, the model uses a mix of Bayesian weights (for the subnetwork) and deterministic MAP weights (for everything else) to produce a predictive distribution.

Key Insights and Results

Quality Over Quantity: The core insight is that capturing rich dependencies (covariances) between a few weights is far more valuable for uncertainty estimation than treating all weights as independent. Subnetwork inference "prunes" the variance of unimportant weights to zero to make the Bayesian math tractable, while keeping the weight values themselves to preserve accuracy.

Capturing "In-Between" Uncertainty: Traditional diagonal approximations often fail to show high uncertainty in the empty spaces between data clusters. Subnetwork inference captures these correlations, correctly signaling high uncertainty in unexplored regions.

Comparison of Wasserstein vs Random subnetwork selection on 1D regression

Selection Matters: As shown in 1D regression tasks, using the Wasserstein-based selection strategy significantly outperforms picking a subnetwork at random. Even when the subnetwork is shrunk to just 1% of the weights, the Wasserstein method maintains excellent uncertainty estimates, whereas random selection fails to capture the necessary variance.

Efficiency and Calibration: On complex distribution shift benchmarks like Corrupted CIFAR-10, subnetwork inference proved significantly less overconfident than Diagonal Laplace and VOGN, remaining competitive with Deep Ensembles (the current industry gold standard). Remarkably, for a ResNet-18 (11M parameters), performing inference on just 0.36% of the weights (40k) was enough to outperform full-network diagonal methods.

Limitations and Future Work

  • Multi-Output Scaling: Computing the Jacobian for models with many outputs (e.g., semantic segmentation) remains expensive due to the backward pass required for every output dimension.
  • Prior Tuning: Performance is sensitive to the choice of prior precision, currently requiring cross-validation or heuristic tuning.
  • Hessian Bottleneck: While 6.4GB is manageable, the quadratic memory cost of the Hessian matrix limits the subnetwork to tens of thousands of weights, which is a tiny fraction of massive models like modern Transformers. Future work may explore picking "directions" in weight space (like principal components) rather than axis-aligned specific weights.

Summary updated

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