NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Density of States Estimation for Out-of-Distribution Detection

Warren R. Morningstar, Cusuh Ham, Andrew G. Gallagher, Balaji Lakshminarayanan, Alexander A. Alemi, Joshua V. Dillon

TL;DR

This paper introduces DoSE, a novel method for detecting out-of-distribution (OOD) data by leveraging the statistical physics concept of "density of states." DoSE measures the typicality of various model statistics, offering a more robust OOD detection capability than traditional likelihood-based methods, and achieves state-of-the-art performance on challenging benchmarks.

What Problem Does This Paper Address?

Machine learning models often assume that inference data follows the same distribution as training data. When faced with out-of-distribution (OOD) data, these models can produce incorrect predictions with high confidence, posing risks in critical applications like autonomous driving and medical diagnosis. While OOD detection methods exist, a surprising finding is that many probabilistic models assign higher likelihoods to OOD data than in-distribution data. This is because the "typical set" of data points (where most data lies) might not coincide with the region of highest probability density. Existing methods often struggle with this, especially in high-dimensional settings, and many require labeled data or OOD examples for training, which are not always available.

Methods

The core of DoSE is inspired by the statistical physics concept of "density of states," which describes the number of configurations a system can take for a given value of a statistic. Instead of directly using a model's likelihood, DoSE estimates the "probability of the model probability" or, more generally, the frequency of various model statistics.

Here's how it works:

  1. Summary Statistics: For a trained generative model, DoSE extracts multiple summary statistics from the data. These can be derived from the model's internal representations or outputs (e.g., posterior entropy, KL divergence, log-likelihood of latent variables, Jacobian determinants).
  2. Density Estimation: Nonparametric density estimators, such as Kernel Density Estimation (KDE) or one-class Support Vector Machines (SVM), are used to model the distribution of these summary statistics on the in-distribution training data. This effectively learns what constitutes "typical" values for these statistics.
  3. Typicality Measurement: For a new, unseen data point, its summary statistics are computed. DoSE then evaluates how "typical" these statistics are according to the learned density estimators.
  4. OOD Detection: Data points whose statistics fall into low-density regions of the learned distributions are flagged as OOD. DoSE combines the typicality scores from multiple statistics, making it more robust than methods relying on a single statistic.

A key advantage is that DoSE is modular and can be applied to any pre-trained model without requiring retraining or OOD examples.

Datasets

The paper evaluates DoSE on several standard datasets and their combinations for OOD detection tasks:

  • In-distribution datasets: MNIST, FashionMNIST, CIFAR10, SVHN, CelebA.
  • OOD datasets: Uniform noise, Gaussian noise, horizontally and vertically flipped versions of the in-distribution datasets, Omniglot, ImageNet-32, CIFAR100.

The paper specifically highlights "hard" OOD dataset pairings, such as FashionMNIST→MNIST and CelebA→CIFAR10/100, which are known to be challenging for existing methods.

Key Insights and Ideas

  • Likelihood is Deceptive: The paper strongly argues and demonstrates that relying solely on a generative model's likelihood for OOD detection is fundamentally flawed, especially in high dimensions. OOD data can often have higher likelihoods than in-distribution data.
  • Typicality is Key: The core insight is that measuring the typicality of various model statistics, rather than just their raw probability, is a more reliable indicator of whether a data point belongs to the in-distribution.
  • Statistical Physics Analogy: Drawing parallels to statistical mechanics provides a theoretical grounding for why density of states (measuring typicality) is a powerful concept for anomaly detection.
  • Modularity and Generality: DoSE's ability to be applied to any pre-trained model, regardless of its architecture or training objective, makes it a highly practical and versatile tool.
  • Multiple Statistics are Better: Combining information from multiple summary statistics significantly improves robustness and performance compared to using a single statistic, even if some statistics are uninformative.

Key Results

  • State-of-the-Art Performance: DoSE (both KDE and SVM variants) achieves state-of-the-art performance on established OOD detection benchmarks, particularly on the "hard" dataset pairings.
  • Superior AUROC: In Table 1, DoSE consistently achieves higher Area Under the ROC Curve (AUROC) scores across various dataset pairings compared to baselines like likelihood, WAIC, TT, and LLR. For instance, on the CelebA→CIFAR10 pairing, DoSE achieves an AUROC of 0.949, significantly outperforming others.
  • Robustness to Uninformative Statistics: Experiments show that DoSE is remarkably robust to the inclusion of uninformative statistics. Even with a large number of "useless" statistics, the performance degradation is minimal, suggesting that careful selection of statistics might not be as critical as initially thought.
  • Improved Visualizations: Figure 2 and Figure 4 visually demonstrate how DoSE can find more optimal decision boundaries in multi-dimensional statistic spaces where likelihood-based methods fail.

Limitations and Future Work

  • Computational Cost: While DoSE is modular, computing multiple summary statistics and running density estimators can add computational overhead compared to simpler methods.
  • Choice of Statistics: Although the paper shows robustness to uninformative statistics, the optimal choice of statistics for a given model and task might still require some domain knowledge or experimentation.
  • Memorization: The paper acknowledges that deep generative models can exhibit significant memorization, leading to high expected calibration error (ECE). They address this with techniques like reverse beta-annealing for VAEs and L2-regularization for Glow, but it remains a general challenge in deep learning.
  • Future Work: The authors suggest exploring more sophisticated density estimators and investigating how to automatically select the most informative statistics for a given model. They also hint at potential applications in areas like model fairness and safety-critical systems.

Summary updated

BibTeX
@inproceedings{morningstar2021density,
  author = {Warren R. Morningstar and Cusuh Ham and Andrew G. Gallagher and Balaji Lakshminarayanan and Alexander A. Alemi and Joshua V. Dillon},
  title = {{Density of States Estimation for Out-of-Distribution Detection}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2021},
  url = {https://openreview.net/forum?id=SlN65oKvWc},
}
Figure