Abstract
Bayesian inference was once a gold standard for learning with neural networks, providing accurate full predictive distributions and well calibrated uncertainty. However, scaling Bayesian inference to modern deep architectures is challenging due to the high dimensionality of the parameter space. We present Subspace Inference (SI), a framework that performs Bayesian inference within a low-dimensional subspace of the model weights. By carefully constructing these subspaces—using PCA of the SGD trajectory or low-loss curves—we can apply powerful Bayesian techniques to models with millions of parameters, achieving superior uncertainty calibration and competitive predictive performance.
Introduction
While Bayesian Neural Networks (BNNs) theoretically offer the "gold standard" for deep learning by providing well-calibrated uncertainty, they are notoriously difficult to implement at scale. Modern architectures often contain millions of parameters, making posterior sampling computationally prohibitive. Traditional approximations, such as Variational Inference (VI) or Monte Carlo Dropout, frequently sacrifice the richness of the Bayesian posterior for the sake of scalability. Subspace Inference (SI) addresses this gap by restricting the search for model weights to a tiny, carefully chosen subspace, enabling the use of exact Bayesian tools on massive models.
Methodology: Inference in Low-Dimensional Subspaces
The core principle of SI is to perform inference within a low-dimensional subspace $\mathcal{S} \subset \mathbb{R}^d$. Instead of operating in the full parameter space, we define the weights as: $$w = \hat{w} + Pz$$ where $\hat{w}$ is a reference weight vector (e.g., a pre-trained solution), $P$ is a projection matrix whose columns define the subspace directions, and $z$ is a low-dimensional vector (typically 5 to 20 dimensions).
Subspace Construction
The effectiveness of SI depends heavily on the choice of the subspace. The authors propose three primary methods:
- Random Subspaces: Directions are drawn randomly, serving as a baseline.
- PCA of the SGD Trajectory: Snapshots of weights are taken during the final stages of Stochastic Gradient Descent (SGD). Principal Component Analysis (PCA) is then used to identify the directions of maximum weight variation. This method is highly practical and captures the local geometry of the loss landscape.
- Curve Subspaces: This method identifies a non-linear, low-loss path connecting two independently trained solutions, capturing a richer, non-Gaussian set of models.
Once the subspace is defined, standard Bayesian tools like Elliptical Slice Sampling (ESS) or Variational Inference (VI) are applied to the low-dimensional $z$. The final predictions are generated via Bayesian Model Averaging (BMA).
Experimental Evaluation
The authors evaluated SI across synthetic regression, UCI benchmarks, and large-scale image classification tasks (CIFAR-10/100) using architectures like VGG-16 and WideResNet-28x10.
Key Results
- Uncertainty Calibration: On regression tasks, SI produces uncertainty that grows naturally as the model moves away from training data, mimicking Gaussian Process behavior.
- Predictive Accuracy: On CIFAR-100, SI with a PCA subspace achieved 81.55% accuracy, outperforming standard SGD, MC-Dropout, and KFAC-Laplace.
- Efficiency: Constructing the PCA subspace is computationally inexpensive, taking only minutes for large models after initial training.
Discussion and Insights
A central insight of this work is that subspace quality matters more than inference quantity. A rich subspace, such as one derived from the SGD trajectory, allows even simple inference methods to outperform complex ones acting on the full parameter space. Furthermore, the authors found that "tempering" the posterior (using a temperature hyperparameter $T$) is crucial to prevent the posterior from concentrating too tightly around the MLE solution, which otherwise leads to overconfidence.
While SI requires an initial step to find the subspace, its ability to capture functional diversity in just 5–20 dimensions for models with millions of parameters represents a significant step toward making "gold standard" Bayesian deep learning practical for modern AI.
Summary updated