How Good is the Bayes Posterior in Deep Neural Networks Really?

Florian Wenzel, Kevin Roth, Bastiaan S. Veeling, Jakub Swiatkowski, Linh Tran, Stephan Mandt, Jasper Snoek, Tim Salimans, Rodolphe Jenatton, Sebastian Nowozin

Abstract

Despite the promise of improved uncertainty quantification, Bayesian neural networks (BNNs) have seen limited industrial deployment. This work demonstrates that the posterior predictive induced by the true Bayes posterior ($T=1$) yields systematically worse predictions compared to simpler methods like SGD. Performance is significantly improved through "cold posteriors" ($T < 1$) that overcount evidence—a common heuristic that deviates from Bayesian theory. By ruling out inference errors through careful MCMC sampling, we suggest that the root cause lies in fundamentally flawed priors for deep learning.

Introduction: The Bayesian Mystery

In theory, Bayesian inference should be the gold standard for deep learning. By marginalizing over the posterior distribution of parameters, BNNs should provide superior generalization and robust uncertainty estimates. However, practitioners often find that they must "cool" the posterior by scaling the log-posterior with a temperature $T < 1$. This sharpening of the distribution violates the Bayesian paradigm, where $T=1$ is theoretically optimal. This paper investigates whether this "cold posterior effect" is a result of poor inference or a deeper model specification issue.

Methodology: High-Fidelity Sampling

To ensure that the observed performance gap isn't simply an artifact of poor posterior approximation, the authors employ high-fidelity Stochastic Gradient MCMC (SG-MCMC). They introduce layerwise preconditioning and cyclical time stepping to improve sampling accuracy. Crucially, they validate their SG-MCMC implementation against Hamiltonian Monte Carlo (HMC)—the "gold standard" of MCMC—on smaller models.

Comparison of HMC and SG-MCMC across different MLP depths shows that the SG-MCMC sampler accurately tracks the gold-standard HMC results, ruling out sampling error as the cause of the cold posterior effect.

The results show that SG-MCMC closely matches HMC, confirming that the "cold posterior" phenomenon is not a failure of the sampling algorithm itself.

The Cold Posterior Effect

Experiments across computer vision (ResNet-20 on CIFAR-10) and NLP (CNN-LSTM on IMDB) reveal a consistent trend: predictive performance is maximized at temperatures much lower than $1$.

Test accuracy and cross-entropy as a function of temperature $T$. Performance peaks at $T \ll 1$, while the true Bayes posterior ($T=1$) performs worse than the SGD baseline.

As shown above, at $T=1$, the model's accuracy and cross-entropy are significantly worse than at $T=0.1$ or even a simple SGD point estimate. This effect persists even when removing "non-Bayesian" components like data augmentation or batch normalization, suggesting a fundamental issue with the model's prior or likelihood.

Investigating the Cause: The Prior as the Prime Suspect

The authors systematically evaluate several hypotheses to explain why $T=1$ fails:

  • Is it the sampler? No, as shown by HMC validation.
  • Is it stochastic noise? No, varying batch sizes does not eliminate the effect.
  • Is it the prior? Likely. Standard Gaussian priors in weight space do not induce a diverse range of functions. Instead, they produce "concentrated" functions that lack the necessary inductive bias for complex tasks like image classification.

Conclusion

The "cold posterior" effect highlights a significant gap between Bayesian theory and deep learning practice. While cooling the posterior is a successful heuristic, it serves as a "patch" for poorly specified priors. Future research should focus on developing functional priors that better capture the inductive biases of successful deep architectures, rather than solely focusing on more accurate posterior approximations of flawed models.

Summary updated

Abstract

During the past five years the Bayesian deep learning community has developed increasingly accurate and efficient approximate inference procedures that allow for Bayesian inference in deep neural networks. However, despite this algorithmic progress and the promise of improved uncertainty quantification and sample efficiency there are---as of early 2020---no publicized deployments of Bayesian neural networks in industrial practice. In this work we cast doubt on the current understanding of Bayes posteriors in popular deep neural networks: we demonstrate through careful MCMC sampling that the posterior predictive induced by the Bayes posterior yields systematically worse predictions compared to simpler methods including point estimates obtained from SGD. Furthermore, we demonstrate that predictive performance is improved significantly through the use of a "cold posterior" that overcounts evidence. Such cold posteriors sharply deviate from the Bayesian paradigm but are commonly used as heuristic in Bayesian deep learning papers. We put forward several hypotheses that could explain cold posteriors and evaluate the hypotheses through experiments. Our work questions the goal of accurate posterior approximations in Bayesian deep learning: If the true Bayes posterior is poor, what is the use of more accurate approximations? Instead, we argue that it is timely to focus on understanding the origin of the improved performance of cold posteriors.
BibTeX
@inproceedings{wenzel2020how,
  author = {Florian Wenzel and Kevin Roth and Bastiaan S. Veeling and Jakub Swiatkowski and Linh Tran and Stephan Mandt and Jasper Snoek and Tim Salimans and Rodolphe Jenatton and Sebastian Nowozin},
  title = {{How Good is the Bayes Posterior in Deep Neural Networks Really?}},
  booktitle = {International Conference on Machine Learning},
  year = {2020},
  url = {https://openreview.net/forum?id=r2NZcCAkEWc},
}
Figure