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

Streamlining Prediction in Bayesian Deep Learning

Rui Li, Marcus Klasson, Arno Solin, Martin Trapp

Introduction

Bayesian Deep Learning (BDL) provides excellent uncertainty quantification, a critical feature for models deployed in high-stakes environments like medical diagnosis and autonomous driving. In these settings, knowing when a model is uncertain is just as important as the prediction itself. However, BDL typically relies on slow Monte Carlo sampling to make predictions. This paper introduces a deterministic, single-forward-pass method that uses local linearisation and Gaussian approximations to analytically compute predictions. The result is a faster, plug-and-play approach that matches or beats sampling in accuracy and calibration across MLPs, CNNs, and Transformers.

Practical applications of Bayesian Deep Learning include outlier detection and input sensitivity analysis.

The Bottleneck of Bayesian Deep Learning

Standard deep learning models learn a single point estimate for their weights. BDL, on the other hand, learns a distribution over the network's weights. While this yields robust uncertainty estimates, it introduces a major practical bottleneck during inference.

To make a prediction, a BDL model must integrate over a massive, high-dimensional parameter space. The standard workaround is Monte Carlo (MC) sampling—running the network dozens or hundreds of times with different sampled weights and averaging the results. This introduces massive computational overhead, making BDL too slow for many real-world, real-time applications. The authors aim to bypass this sampling process entirely, streamlining BDL predictions into a single, analytical forward pass.

Analytical Propagation: A Deterministic Approach

The authors propose propagating the probability distribution of the data analytically through the network layer by layer. To make the math tractable, they rely on two key approximations:

  1. Local Gaussian Approximations at Linear Layers: At every linear (or convolutional) layer, the pre-activation distribution is approximated as a Gaussian. To do this efficiently, the authors assume that the activations from the previous layer and the weights of the current layer are independent.
  2. Local Linearisation of Activation Functions: Pushing a Gaussian distribution through a non-linear activation function (like ReLU) usually destroys its Gaussian nature. The authors solve this using a first-order Taylor expansion around the mean of the pre-activation. This locally linearises the activation function, allowing the distribution to pass through analytically.
Analytical propagation of distributions through an MLP and an Attention Layer using local approximations.

Handling Complex Architectures: The authors extend this logic to modern architectures like Transformers. Because pushing distributions through a Softmax function in Attention layers is mathematically messy, they treat the Query and Key matrices deterministically (using their means) and only treat the Value matrix as a random quantity.

Handling Covariance: The paper provides efficient mathematical formulations to handle different posterior covariance structures, ranging from simple diagonal matrices (common in Mean-Field Variational Inference) to complex Kronecker-factored (KFAC) matrices used in Laplace approximations. They even introduce a clever block-retrieval method for KFAC to avoid blowing up GPU memory.

Key Insights and Results

The authors evaluated their method across a wide range of domains, including regression (UCI datasets), image classification (MNIST, CIFAR, ImageNet-R), language modeling (GPT-2 on GLUE), and Out-of-Distribution (OOD) detection.

  • Sampling isn't strictly necessary for good uncertainty: By treating the neural network as a locally linear function, you can analytically propagate uncertainty through the network. Surprisingly, this deterministic approximation often yields better uncertainty estimates than drawing hundreds of Monte Carlo samples.
  • Superior Calibration: On MNIST-like datasets, the proposed method matched baseline accuracy (~97.5%) but drastically improved the Expected Calibration Error (ECE). For instance, using Laplace Approximation, ECE dropped from 0.122 (sampling) to just 0.004 (analytical).
  • Regression Dominance: The method outperformed MC sampling on Negative Log Predictive Density (NLPD) in 11 out of 11 UCI datasets when using Mean-Field Variational Inference (MFVI).
  • Scalability to ViT and GPT-2: The method successfully scaled to Vision Transformers and GPT-2. On CIFAR-10 with a ViT, the analytical method achieved an NLPD of 0.086, compared to 0.170 for standard sampling.
  • Massive Speedups: By avoiding sampling, the method is incredibly fast. For a ViT on CIFAR-10, the analytical forward pass took ~4.35ms, compared to ~190ms for standard Laplace sampling—effectively matching the speed of a standard, non-Bayesian network.
  • Analytical forward passes unlock new capabilities: Because the prediction is a closed-form analytical equation, complex inference tasks become trivial. For example, the authors demonstrate analytical "input sensitivity analysis" (figuring out which pixels drive a prediction). The Bayesian sensitivity maps generated by their method are noticeably less noisy and more interpretable than those from standard deterministic models.

Limitations and Future Work

While highly effective, the method has a few limitations:

  • Independence Assumptions: The method assumes independence between activations and model parameters. The authors note this could lose valuable information, especially when propagating through residual connections.
  • Linearisation Errors: The quality of the Taylor expansion depends heavily on the specific activation function and the scale of the input distribution.
  • Scaling Factor Tuning: The method currently requires a validation set to grid-search a scaling factor for the predictive variance, adding a slight tuning overhead.

Future work will explore ways to relax the independence assumption in residual blocks, scale to tasks with massive numbers of output classes, and use marginal likelihood to optimize the scaling factor instead of relying on grid search.

Summary updated

BibTeX
@inproceedings{li2025streamlining,
  author = {Rui Li and Marcus Klasson and Arno Solin and Martin Trapp},
  title = {{Streamlining Prediction in Bayesian Deep Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=pW387D5OUN},
}
Figure