Bayesian Uncertainty Estimation for Batch Normalized Deep Networks

Mattias Teye, Hossein Azizpour, Kevin SmithICML 2018

The Core Idea

This paper demonstrates that training a deep neural network with Batch Normalization (BN) is mathematically equivalent to approximate inference in a Bayesian model. By simply sampling random mini-batches from the training set during inference—a technique the authors call Monte Carlo Batch Normalization (MCBN)—researchers can generate high-quality uncertainty estimates from standard, pre-trained networks without any architectural changes or specialized training.

The Problem: Overconfident Networks

Deep neural networks are notoriously overconfident; they will often provide a high-certainty prediction even when the input is far outside their training distribution. In safety-critical fields like autonomous driving or medical diagnosis, knowing when a model is uncertain is just as important as the prediction itself.

While Bayesian Neural Networks (BNNs) offer a formal way to handle uncertainty, they are traditionally difficult to scale. A popular workaround is Monte Carlo Dropout (MCDO), which treats dropout layers as a way to sample from a model's posterior distribution. However, many modern architectures have moved away from dropout in favor of Batch Normalization. This paper asks a practical question: Can we exploit the inherent "noise" in Batch Norm to get Bayesian uncertainty for free?

Methods: Monte Carlo Batch Normalization (MCBN)

The authors show that the stochasticity introduced by mini-batch statistics in BN can be cast as Variational Inference.

In standard BN, we use the mean and variance of the current mini-batch during training, but switch to fixed "population" statistics during inference. MCBN changes this paradigm by keeping the stochasticity alive during inference:

  1. Keep the stochasticity: Instead of using fixed statistics, construct several random mini-batches from the training data during the inference phase.
  2. Multiple Passes: For a single test input, run multiple forward passes, each time pairing the input with a different random training mini-batch.
  3. Aggregate: The mean of these passes becomes the final prediction, and the variance across the passes serves as the estimate of model uncertainty.
1D regression demonstrating MCBN mean and confidence intervals.

This approach requires no retraining and can be applied to almost any existing network that uses BN.

Key Insights

  • BN as a Bayesian Proxy: The randomness of which samples end up in a mini-batch during training acts as a form of Bayesian noise. This noise effectively "samples" from the distribution of possible model weights.
  • Uncertainty for "Free": Unlike other Bayesian methods that require complex modifications or training from scratch, MCBN can be applied directly to "off-the-shelf" models.
  • Normalization of Metrics: The paper suggests using "Constant Uncertainty" baselines (CUBN/CUDO) to normalize metrics like Predictive Log Likelihood (PLL), making it easier to see how much a Bayesian method actually improves over a trivial "fixed-guess" uncertainty.

Key Results

The authors evaluated MCBN across several domains, including standard regression datasets, image classification (CIFAR-10), and image segmentation (CamVid, PASCAL-VOC).

  • Competitive Performance: On regression tasks, MCBN performed on par with or better than Monte Carlo Dropout (MCDO) and Multiplicative Normalizing Flows (MNF). For example, on the Boston Housing dataset, MCBN achieved a normalized CRPS (a measure of uncertainty quality) of 8.50%, significantly higher than MCDO's 3.06%.
  • Correlation with Error: The authors introduced visualizations showing that as the model’s estimated uncertainty increases, the actual prediction error also tends to increase. This confirms the uncertainty estimates are meaningful and not just random noise.
  • Segmentation Clarity: In visual tasks, MCBN produced intuitive uncertainty maps, showing high uncertainty specifically around object boundaries and in ambiguous regions.
MCBN performance across regression tasks showing correlation between uncertainty and error (left), and image segmentation tasks highlighting uncertainty around object boundaries (right).

Limitations and Future Work

While powerful, MCBN comes with a few practical considerations:

  • Batch Size Sensitivity: The quality of MCBN is highly dependent on the mini-batch size used during inference. Performance tends to degrade if the batch size is too small (e.g., $\le 16$).
  • Inference Overhead: Because MCBN requires multiple forward passes (the authors used $T=500$ for regression), it is computationally more expensive at test-time than a standard deterministic network.
  • Data Access: To perform MCBN, you need access to the training data (or a representative subset) during inference to generate the mini-batch statistics. Storing pre-calculated BN statistics could be a potential workaround for this limitation.

Summary updated

BibTeX
@inproceedings{teye2018bayesian,
  author = {Mattias Teye and Hossein Azizpour and Kevin Smith},
  title = {{Bayesian Uncertainty Estimation for Batch Normalized Deep Networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=By-c2s-ubr},
}
Figure