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

Variational Bayesian Last Layers

James Harrison, John Willes, Jasper Snoek

Introduction

Deep neural networks (DNNs) have become the standard for high-performance predictive modeling, yet they suffer from a critical flaw: they are notoriously overconfident. In safety-critical applications, a model that is "confidently wrong" on out-of-distribution (OOD) data can lead to catastrophic failures. While Bayesian Neural Networks (BNNs) offer a principled framework for quantifying uncertainty, their practical adoption is limited by high computational costs, the need for stochastic sampling during inference, and complex training pipelines.

Variational Bayesian Last Layers (VBLLs) address these challenges by providing a deterministic, sampling-free method to transform standard neural networks into partially Bayesian models. By restricting variational inference to the final layer, VBLLs achieve significantly improved uncertainty quantification and OOD detection with minimal computational overhead—as low as 5% additional training time.

The VBLL Framework

The core innovation of VBLLs is a deterministic variational formulation for the network's final layer. Unlike traditional BNNs that rely on Monte Carlo sampling to estimate the loss—a process that introduces significant gradient noise—the authors derive analytical lower bounds on the marginal likelihood. This allows the model to be trained using standard optimizers like AdamW or SGD without the "jitter" typical of stochastic Bayesian methods.

The paper introduces three distinct flavors of VBLL, each suited for different tasks:

  1. Regression: A canonical model for continuous outputs.
  2. Discriminative Classification: This corresponds to Bayesian logistic regression performed on learned features.
  3. Generative Classification: Similar to Gaussian Discriminant Analysis, this variant learns the density of features for each class. By modeling the input distribution directly, it is particularly effective at detecting OOD data.

Crucially, the authors utilize Cholesky factorizations to ensure that the complexity of these layers remains quadratic in the width of the last layer. In practice, adding a VBLL to a large-scale architecture like a Wide ResNet adds almost no noticeable delay to the training or inference pipeline.

Experimental Evaluation

The authors evaluated VBLLs across a diverse range of benchmarks to test accuracy, calibration, and decision-making utility.

Image Classification and OOD Detection

Using a Wide ResNet-28-10 backbone on CIFAR-10 and CIFAR-100, VBLLs demonstrated superior performance in identifying unseen data. On the CIFAR-10 (in-distribution) vs. SVHN (OOD) task, the Discriminative VBLL achieved an AUC of 0.969, outperforming the popular SNGP baseline (0.960). Importantly, VBLLs maintained or slightly improved top-1 accuracy compared to deterministic baselines, proving that uncertainty quantification does not have to come at the cost of raw performance.

Natural Language Processing

In sentiment analysis tasks using features from a pre-trained OPT-175B language model, VBLLs showed significantly lower Expected Calibration Error (ECE) compared to standard Multi-Layer Perceptrons. This improvement was especially pronounced in low-data regimes, where standard models are most prone to overconfidence.

Active Learning and Decision Making

To test the utility of the model's uncertainty in real-world decision-making, the authors applied VBLLs to the "Wheel Bandit" problem. In this contextual bandit task, the model must balance exploration and exploitation. VBLL strongly outperformed top-performing baselines in cumulative regret, demonstrating that its uncertainty estimates are not just statistically sound but practically useful for guiding exploration.

Key Insights

  • Sampling-Free Training: By avoiding weight sampling, VBLLs provide stable, low-variance gradients, making them a drop-in replacement for standard output layers.
  • Quadratic Decision Regions: The generative classification model produces quadratic rather than linear decision boundaries. This allows the model to be sensitive to Euclidean distance in the feature space, a vital property for robust OOD detection.
  • Interpretability: The authors provide a reformulated set of hyperparameters that are more intuitive for practitioners, such as "target predictive variance," simplifying the often-difficult task of prior selection in Bayesian modeling.

Limitations and Future Work

While VBLLs are highly efficient, the generative classification model currently utilizes diagonal covariance matrices to maintain linear complexity relative to feature dimensions. Future research into sparse or structured covariances could further enhance performance. Additionally, as a "last-layer-only" approach, VBLLs do not capture uncertainty in the feature-learning process itself. The authors suggest that extending this work toward recursive Bayesian least squares or collapsed variational inference could bridge the gap between last-layer efficiency and full-network Bayesian robustness.

Summary updated

BibTeX
@inproceedings{harrison2024variational,
  author = {James Harrison and John Willes and Jasper Snoek},
  title = {{Variational Bayesian Last Layers}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=Sx7BIiPzys},
}
Figure