Make Me a BNN: A Simple Strategy for Estimating Bayesian Uncertainty from Pre-trained Models

Gianni Franchi, Olivier Laurent, Maxence Leguéry, Andrei Bursuc, Andrea Pilzer, Angela Yao

Abstract

Deep Neural Networks (DNNs) often exhibit overconfidence, particularly when encountering out-of-distribution (OOD) data. While Bayesian Neural Networks (BNNs) provide a framework for uncertainty quantification, their computational overhead and training instability hinder large-scale adoption. We present the Adaptable Bayesian Neural Network (ABNN), a post-hoc strategy that transforms pre-trained deterministic models into BNNs by fine-tuning only their normalization layers. ABNN achieves state-of-the-art OOD detection and calibration with minimal computational cost, offering a practical "Bayesian upgrade" for modern architectures.

Introduction: The Overconfidence Problem

Standard DNNs are typically trained to provide point estimates, leading to high-certainty predictions even for incorrect or unfamiliar inputs. Bayesian approaches mitigate this by treating weights as distributions, but traditional BNNs are notoriously difficult to scale and stabilize. Alternatives like Deep Ensembles are effective but require training multiple models from scratch, which is prohibitively expensive for large-scale production environments. The authors seek a middle ground: a method as easy to use as a pre-trained model but as reliable as a BNN.

Methodology: Adaptable Bayesian Neural Networks

The ABNN approach focuses on the latent space rather than the entire weight space. By targeting normalization layers (e.g., Batch Normalization, LayerNorm), which constitute a tiny fraction of total parameters (e.g., 0.16% for a ResNet-50), the method achieves remarkable efficiency and stability.

Bayesian Normalization Layers (BNL)

Standard normalization layers are replaced with BNLs that inject Gaussian noise ($\epsilon$) into the affine parameters ($\gamma$ and $\beta$). This effectively turns the deterministic output of a layer into a stochastic one, allowing the model to sample different predictive paths during inference.

Post-hoc Fine-tuning and Diversity

Starting from a model already trained on a task (like ImageNet), only the $\gamma$ and $\beta$ parameters are fine-tuned for a few epochs while the rest of the network remains frozen. To capture multi-modal uncertainty, a small ensemble of ABNNs is trained. Diversity is enforced through a "random prior" perturbation—a class-dependent random weight in the loss function that encourages ensemble members to become "experts" in different areas.

Figure 3: Left: ABNN achieves a superior trade-off between training efficiency and OOD detection (FPR-95) compared to baselines. Right: Conceptual illustration of how ABNN captures uncertainty (disagreement among ensemble members) where a single model makes an overconfident error.

Key Insights and Stability

A critical advantage of ABNN is its training stability. Traditional BNNs apply noise directly to weights, making gradients highly volatile. ABNN applies noise to the latent space (activations inside normalization layers), which mathematically results in lower gradient variance. Furthermore, because normalization layers are ubiquitous in modern architectures like ResNets and Vision Transformers (ViTs), ABNN serves as a near-universal "free" upgrade that can be applied without changing the underlying architecture.

Experimental Results

The authors evaluated ABNN across a wide variety of computer vision tasks, including ImageNet classification and semantic segmentation.

  • Out-of-Distribution Detection: On CIFAR-10, ABNN reached an FPR95 of 15.1%, significantly outperforming the single model baseline (23.6%) and even beating Deep Ensembles (15.5%) while being much faster to train.
  • Calibration: On ImageNet with a ViT backbone, ABNN achieved an Expected Calibration Error (ECE) of 4.32%, a massive improvement over the single model's 5.2% and the Laplace method's 10.8%.
  • Segmentation Performance: In semantic segmentation, ABNN set new state-of-the-art results on the MUAD dataset, reaching an mIoU of 61.96% and an AUC of 91.55% for anomaly detection.

Conclusion and Future Work

ABNN provides a scalable, efficient path toward reliable uncertainty estimation in deep learning. While it may not explore the weight space as exhaustively as full ensembles, its performance-to-cost ratio is unmatched. Future research may extend this normalization-centric Bayesian approach to Large Language Models (LLMs), where LayerNorm is standard and uncertainty quantification is a growing concern.

Summary updated

BibTeX
@inproceedings{franchi2023make,
  author = {Gianni Franchi and Olivier Laurent and Maxence Leguéry and Andrei Bursuc and Andrea Pilzer and Angela Yao},
  title = {{Make Me a BNN: A Simple Strategy for Estimating Bayesian Uncertainty from Pre-trained Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure