Bayesian dark knowledge

Anoop Korattikara Balan, Vivek Rathod, Kevin P. Murphy, Max Welling

TL;DR

This paper introduces "Bayesian Dark Knowledge," a method that captures the rich uncertainty of Bayesian posterior distributions and compresses them into a single, efficient deep neural network. By using a Stochastic Gradient Langevin Dynamics (SGLD) "teacher" to train a "student" network, the authors achieve the predictive performance and calibration of an ensemble of models at the computational cost of just one.

The Problem: Overconfident Neural Networks

Deep Neural Networks (DNNs) are powerful but notoriously overconfident. In high-stakes applications like active learning or medical diagnosis, knowing when a model is uncertain is as important as the prediction itself.

The principled way to handle this is Bayesian inference, which calculates a posterior distribution over model parameters. However, this comes with a heavy "Bayesian tax":

  1. Monte Carlo (MCMC) methods are accurate but require storing and running hundreds or thousands of model versions at test time, which is too slow and memory-intensive for real-world deployment.
  2. Variational Bayes (VB) or Expectation Propagation (EP) are faster but often rely on simplistic assumptions (like Gaussian distributions) that fail to capture the complex, multi-modal nature of neural network weight spaces.

The authors seek a middle ground: the accuracy of MCMC with the test-time efficiency of a standard "plug-in" neural network.

The Solution: Distilling Bayesian Dark Knowledge

The authors propose a distillation approach. Inspired by the concept of "Dark Knowledge"—where a small student network learns to mimic the softened outputs of a larger teacher ensemble—they apply this to the Bayesian setting:

  1. The Teacher (SGLD): They use Stochastic Gradient Langevin Dynamics (SGLD), an online MCMC method that behaves like SGD but adds a specific amount of Gaussian noise to the gradients. This allows the teacher to "wander" through the posterior distribution of weights, effectively generating an infinite ensemble of models.
  2. The Student (SNN): A single "student" network is trained to minimize the Kullback-Leibler (KL) divergence between its own predictive distribution and the teacher's average predictive distribution.
  3. Training Procedure: Unlike standard distillation which uses a fixed teacher, here the teacher and student are trained simultaneously. As the teacher explores the parameter space, the student constantly updates its parameters to approximate the teacher's integrated predictive density.
  4. Handling Regression: For regression tasks, the student is designed to output both a mean ($\mu$) and a variance ($\sigma^2$), allowing it to explicitly model data-dependent uncertainty.

Key Insights and Results

The authors evaluated their method on several benchmarks, including a Toy 2D Classification task, MNIST, a Toy 1D Regression task, and the Boston Housing dataset.

  • Capturing the "Dark Knowledge": The teacher’s predictive distribution contains hidden information about which classes are similar and where the model is unsure. By training on these probability distributions rather than hard labels, the student learns a much more nuanced representation of the world.
  • Efficiency without Sacrifice: Distillation reduces the storage and test-time costs of SGLD by a factor of 10,000x, while losing very little predictive accuracy.
  • Competitive Performance: On MNIST, the distilled SGLD achieved a test error of 1.307%, significantly better than standard SGD (1.536%) and competitive with more complex methods. It also achieved higher log-likelihoods, indicating it is less prone to overconfident errors.
2D Classification Decision Boundaries

Visualization of Uncertainty: In 2D toy classification tasks, the distilled student successfully captured the "broad" uncertainty regions found by the gold-standard Hamiltonian Monte Carlo (HMC). In contrast, standard SGD produced sharp, overconfident boundaries far from the training data.

1D Regression Uncertainty

Similarly, in 1D regression tasks, the distilled model successfully learned to output wider variance bounds in regions with sparse data, mimicking the uncertainty profile of the full SGLD ensemble.

Limitations and Future Work

  • SGLD Bias: SGLD is an approximate MCMC method and introduces a slight bias. While it could be replaced with exact methods like HMC, doing so would drastically increase training time.
  • High-Dimensional Data Sampling: For the student to learn the teacher's distribution everywhere, it needs to see many input points. In high dimensions (like images), simply adding Gaussian noise to inputs might not be enough to explore the manifold where uncertainty matters most.
  • Variance Reduction: Future work could focus on reducing the variance of the distillation algorithm, perhaps by keeping a running "reservoir" of teacher parameters.

Summary updated

BibTeX
@inproceedings{balan2015bayesian,
  author = {Anoop Korattikara Balan and Vivek Rathod and Kevin P. Murphy and Max Welling},
  title = {{Bayesian dark knowledge}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2015},
  url = {https://openreview.net/forum?id=H1-Uwwb_-S},
}
Figure