Noise Contrastive Priors for Functional Uncertainty

Danijar Hafner, Dustin Tran, Timothy Lillicrap, Alex Irpan, James Davidson

TL;DR

This paper introduces Noise Contrastive Priors (NCPs), a novel method to improve uncertainty estimation in neural networks, especially for out-of-distribution (OOD) data. By training models to be uncertain on noisy inputs, NCPs effectively prevent overconfident predictions on unseen data and enhance active learning performance.

What Problem Does This Paper Address?

A major challenge in applying neural networks to real-world scenarios is their tendency to produce overconfident predictions when faced with data that differs from their training distribution. This is particularly problematic in fields like healthcare or autonomous systems, where incorrect, confident predictions can have serious consequences. While Bayesian Neural Networks (BNNs) offer a principled way to quantify uncertainty, specifying appropriate priors on network weights is difficult and often leads to poor generalization on OOD inputs. Existing methods struggle to reliably distinguish between epistemic uncertainty (lack of knowledge) and aleatoric uncertainty (inherent noise), which is crucial for tasks like active learning where we want to acquire informative data points.

Methods

The core innovation is Noise Contrastive Priors (NCPs). Instead of placing priors directly on network weights (which is hard to interpret and control for function behavior), NCPs introduce a "data prior." This prior is designed to:

  • Input Prior: Add noise to the input data, effectively creating "out-of-distribution" samples during training. This encourages the model to learn to be uncertain when presented with slightly perturbed inputs.
  • Output Prior: For these noisy inputs, the model is trained to output a high-entropy (i.e., very uncertain) distribution.

This is achieved by modifying the loss function to include a term that penalizes the model for being confident on these artificially generated noisy inputs. The authors draw inspiration from Noise Contrastive Estimation (NCE) to approximate the difficult-to-define OOD distribution. NCPs are designed to be compatible with various uncertainty-aware models, including Bayesian Neural Networks and even deterministic models that output uncertainty estimates.

Datasets

The paper evaluates NCPs on two main datasets:

  • Toy 1D Regression Task: A synthetic dataset designed to have a distributional shift between training and testing data, specifically to test OOD generalization and active learning.
  • Flight Delays Dataset: A large-scale, real-world regression benchmark with 700K training and 100K test examples, used to demonstrate scalability and performance on a substantial dataset.

Key Insights and Ideas

  • Data Priors are More Interpretable: Placing priors directly in the "data space" (inputs and outputs) is more intuitive and controllable for influencing the network's functional behavior than weight-space priors.
  • NCPs Prevent OOD Overconfidence: By explicitly training the model to be uncertain on noisy inputs, NCPs effectively prevent it from making confident, incorrect predictions on data outside the training distribution.
  • Separating Uncertainty Types: NCPs help models better distinguish between epistemic uncertainty and aleatoric noise, which is crucial for effective active learning.
  • Scalability: The method is shown to be scalable to large datasets, a significant advantage for real-world applications.

Key Results

  • Improved Active Learning: Models trained with NCPs significantly outperform baselines in active learning scenarios, selecting more informative data points and achieving lower error (RMSE) and better predictive accuracy (NLPD).
  • Reduced OOD Overfitting: On the toy 1D regression task, NCPs prevent models from overfitting to the training distribution and generalizing poorly to unseen data, as visualized in Figure 1.
  • State-of-the-Art Performance: On the large-scale flight delays dataset, NCPs achieve state-of-the-art results, significantly improving upon previously published benchmarks.
  • Robustness to Noise: The method is shown to be robust to the choice of input noise distribution and variance, making it practical to implement.

Limitations and Future Work

  • Approximation of OOD: The paper relies on an approximation of OOD inputs by adding noise. While effective, it's an approximation and might not perfectly capture all OOD scenarios.
  • Hyperparameter Tuning: While robust, the choice of input noise variance and the weighting of the NCP loss term are hyperparameters that still need to be tuned.
  • Future Work: The authors suggest exploring NCPs in other domains like image classification (using techniques like mixup) and for learning with sparse or missing data. They also note that data priors can capture properties like periodicity or spatial invariance, potentially offering a scalable alternative to Gaussian Process priors.

Summary updated

Abstract

Obtaining reliable uncertainty estimates of neural network predictions is a long standing challenge. Bayesian neural networks 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.
BibTeX
@inproceedings{hafner2018noise,
  author = {Danijar Hafner and Dustin Tran and Timothy Lillicrap and Alex Irpan and James Davidson},
  title = {{Noise Contrastive Priors for Functional Uncertainty}},
  booktitle = {Uncertainty},
  year = {2018},
}
Figure