Abstract
Obtaining reliable uncertainty estimates of neural network predictions is a long standing challenge. Bayesian neural networks (BNNs) have been proposed as a solution, but it remains open how to specify their prior. In particular, the common practice of an independent normal prior in weight space imposes relatively weak constraints on the function posterior, allowing it to generalize in unforeseen ways on inputs outside of the training distribution. We propose noise contrastive priors (NCPs) to obtain reliable uncertainty estimates. The key idea is to train the model to output high uncertainty for data points outside of the training distribution. NCPs do so using an input prior, which adds noise to the inputs of the current mini batch, and an output prior, which is a wide distribution given these inputs. NCPs are compatible with any model that can output uncertainty estimates, are easy to scale, and yield reliable uncertainty estimates throughout training. Empirically, we show that NCPs prevent overfitting outside of the training distribution and result in uncertainty estimates that are useful for active learning. We demonstrate the scalability of our method on the flight delays data set, where we significantly improve upon previously published results.
Introduction
Deep learning models are often "black boxes" that provide a single prediction without a sense of how certain they are. In safety-critical fields like healthcare or autonomous driving, an overconfident wrong answer can be catastrophic. Standard neural networks are notoriously overconfident when they encounter data they haven't seen before.
While Bayesian Neural Networks (BNNs) attempt to solve this by placing a probability distribution (a "prior") over the network's weights, they face a major hurdle: it is incredibly difficult to know what a "good" weight prior looks like. Common choices, like an independent normal distribution, often fail to prevent the model from being overconfident on out-of-distribution (OOD) data. This paper introduces Noise Contrastive Priors (NCPs), a method that trains models to explicitly output high uncertainty for data points just outside the training distribution.
Methods: Priors in Data Space
The core idea behind NCPs is to define priors in data space—specifying how the model's outputs should behave when the inputs are unfamiliar—rather than weight space. The method consists of two main components:
- Input Prior: The authors take the current mini-batch of training data and add noise to the inputs. This creates a set of points that lie just outside the boundary of the known training distribution.
- Output Prior: For these noisy "OOD" inputs, the model is trained to output a wide, high-entropy distribution (representing high uncertainty).
By adding a term to the loss function—specifically a Kullback–Leibler (KL) divergence—the model is forced to match its predictions on real data while simultaneously matching the high-uncertainty prior on the noisy data. This approach is flexible: it can be used to improve standard BNNs (like Bayes by Backprop) or even deterministic models equipped with an OOD classifier.
Key Insights
- Functional over Weight Priors: It is much more intuitive to specify that a model should be uncertain about "weird" inputs than it is to specify what its internal weights should look like. NCPs shift the focus from weight-space to function-space.
- The Boundary Hypothesis: You don't need to sample the entire infinite space of "everything that isn't the training data." The authors show that encouraging high uncertainty at the boundaries of the training data naturally propagates that uncertainty to the rest of the OOD space.
- Solving "Prior Collapse": In traditional variational inference, the model's uncertainty often "collapses" to the prior during training, making it useless. Because NCPs penalize deviations in the output space rather than the weight space, they are much more resistant to this failure mode.
Empirical Evaluation
The authors evaluated NCPs on two primary benchmarks: a 1D toy regression and the massive Flight Delays dataset (700,000 training examples).
Active Learning and Performance
In active learning scenarios, where the model chooses which data points to learn from next, NCP-based models significantly outperformed standard BNNs. They were better at identifying informative regions and avoided the early overfitting common in baseline models.
On the full Flight Delays dataset, NCPs achieved a Negative Log Predictive Density (NLPD) of 4.38, outperforming previous benchmarks set by Gaussian Processes and Matrix Factorization methods. The method proved robust to the specific type of noise used (Gaussian vs. Uniform) and the scale of that noise, making it a practical "plug-and-play" addition to existing uncertainty-aware architectures.
Limitations and Future Work
While promising, NCPs have some limitations:
- Regression Focus: The paper primarily focuses on regression tasks. Application to image classification remains an area for future empirical demonstration.
- Noise Selection for High Dimensions: Choosing the "right" noise to effectively find the boundary of the training distribution in very high-dimensional spaces (like raw pixels) remains an open challenge.
- KL Direction: The impact of the divergence direction (forward vs. reverse KL) warrants further investigation.
Summary updated