NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Tractable Function-Space Variational Inference in Bayesian Neural Networks

Tim G. J. Rudner, Zonghao Chen, Yee Whye Teh, Yarin Gal

TL;DR

Standard deep learning models are notoriously overconfident, often making "confidently wrong" predictions when faced with data outside their training distribution. This paper introduces a scalable method for performing Function-Space Variational Inference (FSVI) in Bayesian Neural Networks (BNNs). By shifting the focus from weight distributions to the actual functions the network represents, the authors achieve state-of-the-art uncertainty estimation and robustness to distribution shifts, proving highly effective even in high-dimensional, safety-critical tasks like medical diagnosis.

The Problem with Parameter-Space Inference

Bayesian Neural Networks offer a theoretical solution to overconfidence by treating network weights as probability distributions. However, most BNN methods perform inference in parameter space (the weights). This approach suffers from two major drawbacks:

  1. Unintuitive Priors: It is extremely difficult to define a prior distribution over millions of weights that translates into sensible, predictable behavior in the output space.
  2. Poor Calibration: Common approximations, such as Mean-Field Variational Inference, often lead to poor uncertainty estimates in practice because they ignore the complex correlations between weights.

The authors argue that inference should instead be performed in function space—directly modeling the distribution of the network's outputs. While conceptually attractive, function-space inference has historically been mathematically intractable for large-scale neural networks.

The FSVI Solution

The core contribution of this paper is a tractable objective for FSVI that scales to modern deep learning architectures.

  • Function-Space KL Divergence: The authors define a variational objective based on the Kullback-Leibler (KL) divergence between the distribution of functions induced by the model and a functional prior (like a Gaussian Process).
  • Local Linearization: To make the math work for deep networks, they use a first-order Taylor expansion (linearization) around the mean parameters. This allows them to treat the distribution over functions as a Gaussian process locally.
  • Scalable Estimation: Computing the full covariance of these functions is computationally expensive. The authors propose a clever Monte Carlo estimator that partitions parameters, separating the final layer from earlier layers, to compute the KL divergence efficiently.
  • Context Points: To ensure the model remains uncertain in "empty" regions of the input space, they evaluate the function-space KL at "context points"—unlabeled data or noise samples. This anchors the model's behavior and forces uncertainty away from the training data.
Visualizing FSVI on 1D regression and the Two Moons dataset. Uncertainty (variance) increases significantly away from the training data.

Key Insights

  • Functions > Weights: The primary object of interest in machine learning is the mapping from input to output. By regularizing the function rather than the weights, we can explicitly encode requirements like "be uncertain far from the training data."
  • Linearization is "Good Enough": While neural networks are highly non-linear, local linearization provides a sufficient gradient to learn high-quality functional posteriors.
  • Contextual Priors: The choice of where you evaluate your prior (the context points) is a powerful tool. Using related but different datasets (e.g., using KMNIST as context for a FashionMNIST model) significantly boosts out-of-distribution (OOD) detection performance.

Empirical Results

FSVI was evaluated across a variety of benchmarks, consistently outperforming standard Bayesian and non-Bayesian baselines in both accuracy and uncertainty calibration.

  • Image Classification & OOD Detection: On FashionMNIST, FSVI achieved a test accuracy of 93.48% and an Expected Calibration Error (ECE) of 0.010, outperforming Deep Ensembles and standard BNNs. When tasked with distinguishing FashionMNIST from MNIST (OOD data), FSVI reached an AUROC of 99.80%, indicating nearly perfect detection.
Table 1: Comparison of performance metrics on FashionMNIST. FSVI shows superior AUROC for OOD detection.
  • Robustness to Shift: In a "Rotated MNIST" experiment, FSVI maintained much higher entropy (indicating healthy uncertainty) as the digits were rotated, whereas other methods remained overconfident in their incorrect predictions.
  • Safety-Critical Medical Task: The authors tested FSVI on Diabetic Retinopathy diagnosis using the EyePACS and APTOS datasets. Specifically testing "country shift" (training on US data, testing on Indian data), FSVI performed reliably across different patient populations and equipment, proving its utility in high-stakes environments.

Limitations and Future Work

While highly effective, FSVI has a few limitations. The reliance on local linearization is a simplification that may not capture the full complexity of the function-space posterior in all scenarios. Additionally, performance is somewhat dependent on the choice of context points; while heuristics like using monochrome noise work well, a more automated or principled way to select these points could be beneficial. Finally, calculating Jacobians still adds computational cost compared to standard MAP training, though it remains much more scalable than previous function-space methods.

Summary updated

BibTeX
@inproceedings{rudner2022tractable,
  author = {Tim G. J. Rudner and Zonghao Chen and Yee Whye Teh and Yarin Gal},
  title = {{Tractable Function-Space Variational Inference in Bayesian Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=8Cx20oqUBw},
}
Figure