Simple and Principled Uncertainty Estimation with Deterministic Deep Learning via Distance Awareness

Jeremiah Zhe Liu, Zi Lin, Shreyas Padhy, Dustin Tran, Tania Bedrax-Weiss, Balaji Lakshminarayanan

Abstract

Bayesian neural networks (BNN) and deep ensembles are principled approaches to estimate the predictive uncertainty of a deep learning model. However, their practicality in real-time, industrial-scale applications is limited due to their heavy memory and inference cost. This motivates us to study principled approaches to high-quality uncertainty estimation that require only a single deep neural network (DNN). By formalizing the uncertainty quantification as a minimax learning problem, we first identify input distance awareness—the model's ability to quantify the distance of a testing example from the training data in the input space—as a necessary condition for a DNN to achieve high-quality uncertainty estimation. We then propose Spectral-normalized Neural Gaussian Process (SNGP), a simple method that improves the distance-awareness ability of modern DNNs by adding a weight normalization step during training and replacing the output layer with a Gaussian process. On a suite of vision and language understanding tasks and on modern architectures (Wide-ResNet and BERT), SNGP is competitive with deep ensembles in prediction, calibration, and out-of-domain detection, and outperforms other single-model approaches.

The Challenge of Overconfident Networks

Modern deep neural networks (DNNs) are often overconfident, even when they are wrong. This is particularly problematic for "out-of-distribution" (OOD) data—inputs that differ significantly from the training set. In safety-critical applications like autonomous driving or medical diagnosis, a model must signal high uncertainty when it encounters unfamiliar scenarios.

While Bayesian Neural Networks and Deep Ensembles provide high-quality uncertainty, they impose a significant "tax" on memory and computation. SNGP aims to achieve similar reliability using just a single deterministic model in a single forward pass.

Distance Awareness and SNGP

The core insight of this work is distance awareness. Standard DNNs are trained to maximize classification accuracy, focusing only on decision boundaries rather than the density of the training data. SNGP forces the model to care about the geometry of the input space through two key modifications:

  1. Spectral Normalization (SN): By applying SN to the weights of every hidden layer, the model enforces a "bi-Lipschitz" condition. This ensures that the relative distances between data points are preserved as they pass through the network, preventing the model from collapsing different parts of the input space together.
  2. Gaussian Process (GP) Output Layer: Replacing the final dense layer with a GP layer (implemented via a scalable Laplace approximation) allows the model to compute a closed-form posterior variance. This variance acts as a "distance score," signaling higher uncertainty for points far from the training manifold.
Visualizing distance awareness: SNGP (e, j) captures the distance-aware uncertainty of a true Gaussian Process (a, f) on synthetic 2D data, whereas standard ensembles (b) and dropout (c) often fail to identify OOD regions correctly.

Empirical Results

The authors evaluated SNGP across vision (CIFAR-10/100) and language (CLINC OOS) benchmarks. The results demonstrate that SNGP provides a unique balance of accuracy, calibration, and efficiency.

  • Competitive with Ensembles: On CIFAR-10, SNGP achieves calibration (Expected Calibration Error) and OOD detection performance nearly identical to Deep Ensembles, which typically require 10x more resources.
  • Superior Efficiency: SNGP maintains the low latency of a standard deterministic model. As shown in the performance table, SNGP processes examples in roughly 6.25ms, compared to 38.10ms for an ensemble.
  • Robust OOD Detection: SNGP significantly outperforms other single-model methods like MC Dropout or DUQ at identifying out-of-distribution examples, such as SVHN images when trained on CIFAR.
Quantitative comparison on CIFAR-10: SNGP achieves competitive accuracy and calibration to Deep Ensembles with significantly lower latency and superior OOD detection (AUPR).

Conclusion

SNGP provides a simple and principled path toward reliable uncertainty estimation in production environments. By making deterministic networks distance-aware, it bridges the gap between the efficiency of single DNNs and the reliability of complex ensembles. Future work includes refining spectral normalization for convolutional layers and exploring mean-field approximations to further reduce inference overhead.

Summary updated

BibTeX
@inproceedings{liu2020simple,
  author = {Jeremiah Zhe Liu and Zi Lin and Shreyas Padhy and Dustin Tran and Tania Bedrax-Weiss and Balaji Lakshminarayanan},
  title = {{Simple and Principled Uncertainty Estimation with Deterministic Deep Learning via Distance Awareness}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=9A8SWa6UotC},
}
Figure