Variational Inference on the Final-Layer Output of Neural Networks

Yadi Wei, Roni Khardon

Abstract: Traditional neural networks are simple to train but they typically produce overconfident predictions. In contrast, Bayesian neural networks provide good uncertainty quantification but optimizing them is time consuming due to the large parameter space. This paper proposes to combine the advantages of both approaches by performing Variational Inference in the Final layer Output space (VIFO), because the output space is much smaller than the parameter space. We use neural networks to learn the mean and the variance of the probabilistic output. Using the Bayesian formulation we incorporate collapsed variational inference with VIFO which significantly improves the performance in practice. On the other hand, like standard, non-Bayesian models, VIFO enjoys simple training and one can use Rademacher complexity to provide risk bounds for the model. Experiments show that VIFO provides a good tradeoff in terms of run time and uncertainty quantification, especially for out of distribution data.

Introduction

Standard neural networks are notoriously overconfident, often assigning high probabilities to incorrect answers when faced with Out-of-Distribution (OOD) data. While Bayesian Neural Networks (BNNs) address this by learning distributions over model weights, they suffer from high computational costs and optimization difficulties due to the massive dimensionality of the parameter space.

This paper, published in the Transactions on Machine Learning Research (09/2024), introduces VIFO (Variational Inference on the Final-Layer Output). VIFO aims to provide the benefits of Bayesian uncertainty without the overhead by shifting the focus from the parameter space to the output space.

Methodology

The core innovation of VIFO is performing variational inference specifically on the final layer's activations rather than across millions of weights.

Variational Output Distribution

Instead of a deterministic output, the network is designed to produce a mean ($\mu$) and a variance ($\sigma^2$), treating the final output as a Gaussian distribution $q(z|x)$. This reduces the inference problem from millions of dimensions to just the number of output classes.

Collapsed Variational Inference

To mitigate sensitivity to prior assumptions, the authors utilize a hierarchical Bayesian formulation. They derive "collapsed" regularizers (VIFO-mean and VIFO-mv) that automatically adjust the influence of the prior based on the observed data, leading to more stable learning.

Auxiliary Training

To enhance OOD detection, the model undergoes "auxiliary training" using uniform noise. The model is trained to exhibit high uncertainty (high variance) in these empty regions of the input space, preventing overconfident predictions on unseen data types.

The effect of auxiliary training on uncertainty quantification. Without it (left), the model remains overconfident in regions without data; with it (right), the uncertainty band (1-std) correctly expands.

Theoretical Foundations

  • Linear Equivalence: The authors demonstrate that for linear models, VIFO is mathematically equivalent to full Variational Inference, providing a rigorous foundation for the approximation.
  • Generalization Bounds: Due to its structural simplicity, the authors derived risk bounds using Rademacher complexity, offering theoretical guarantees on generalization that are often difficult to obtain for standard BNNs.
  • Expressiveness and Ensembles: While a single VIFO model is theoretically less expressive than a full BNN, the authors show that small ensembles (typically 5 models) can match or exceed the performance of more complex Bayesian methods.

Experimental Results

The researchers evaluated VIFO on standard benchmarks including CIFAR-10, CIFAR-100, SVHN, and STL-10.

Performance and Efficiency

  • Speed: VIFO is approximately 4x faster to train than standard Variational Inference (VI) and only marginally slower than basic non-Bayesian models (SGD).
  • Uncertainty Quantification: VIFO ensembles achieved superior uncertainty quantification on shifted and OOD data compared to strong baselines like Deep Ensembles and SWAG.
  • Accuracy: The method maintains competitive accuracy, ensuring that reliability does not come at the cost of raw performance.
Qualitative comparison of uncertainty estimation between VIFO-mean (a), VI-naive (b), and standard VI-mean (c). VIFO provides a more consistent and reliable uncertainty estimate across the input range.

Conclusion

VIFO represents a significant step toward practical Bayesian deep learning. By restricting inference to the final layer and utilizing collapsed priors, it achieves a "best of both worlds" scenario: the training simplicity of standard networks and the robust uncertainty quantification of BNNs. Future work may explore more informative auxiliary inputs and deeper connections to functional space inference.

Summary updated

BibTeX
@article{wei2024variational,
  author = {Yadi Wei and Roni Khardon},
  title = {{Variational Inference on the Final-Layer Output of Neural Networks}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=mTOzXLmLKr},
}
Figure