TL;DR
Deep neural networks often fail spectacularly when encountering data outside their training distribution, a critical issue for AI safety. This paper introduces a Bayesian approach to Out-of-Distribution (OoD) detection using Variational Autoencoders (VAEs). By treating VAE decoder parameters as uncertain and inferring their full posterior distribution, they develop an information-theoretic measure that robustly identifies out-of-distribution data in both input and latent spaces.
What Problem Does This Paper Address?
Deep neural networks (DNNs) have achieved remarkable success in various domains. However, a significant limitation is their unreliability when presented with data that differs from their training distribution. This "out-of-distribution" (OoD) data can lead to incorrect predictions made with high confidence, posing a serious risk in safety-critical applications. While methods exist to detect such anomalies, a robust and principled solution remains elusive. Existing approaches often rely on density estimation with deep generative models (DGMs), but these can be poorly calibrated, sometimes assigning higher probabilities to OoD data. This paper aims to address this by developing a more robust and information-theoretic approach to unsupervised OoD detection.
Methods
The core of the proposed method lies in treating deep generative models (specifically VAEs) in a Bayesian manner. Instead of fitting point estimates for model parameters (like decoder weights), the authors infer a full posterior distribution over these parameters. This is achieved using Stochastic Gradient Hamiltonian Monte Carlo (SGHMC), a technique for sampling from posterior distributions.
Two variants of Bayesian VAEs (BVAEs) are proposed:
- BVAE Variant 1: Uses a single, fixed encoder and infers a posterior distribution over the decoder parameters.
- BVAE Variant 2: Infers a posterior distribution over both the encoder and decoder parameters, creating an ensemble of VAEs.
The key innovation is the use of an information-theoretic measure derived from the posterior distribution of the model parameters. This measure quantifies the "disagreement" or variation in how different sampled models explain a given input. The intuition is that in-distribution data will be consistently explained by most models, leading to agreement and a high score, while OoD data will be poorly explained by many models, leading to disagreement and a low score. This score can be applied to detect OoD inputs in both the original input space and the learned latent space.
Datasets
The paper evaluates its approach on the following datasets:
- FashionMNIST: Used as both in-distribution and out-of-distribution data.
- MNIST: Used as out-of-distribution data against FashionMNIST.
- SVHN: Used as in-distribution data.
- CIFAR10: Used as out-of-distribution data against SVHN.
The authors also propose a protocol for evaluating latent space OoD detection, which involves training on FashionMNIST and then sampling latent points from a Gaussian distribution.
Key Insights and Ideas
- Bayesian DGMs for Robustness: The paper argues that capturing epistemic uncertainty (uncertainty about model parameters) is crucial for robust OoD detection, similar to how it benefits discriminative models. By inferring a posterior over parameters, DGMs can better reflect this uncertainty.
- Disagreement as an OoD Signal: The core insight is that the disagreement among an ensemble of models (sampled from the posterior) regarding the likelihood of an input is a strong indicator of whether that input is out-of-distribution. In-distribution data leads to model agreement, while OoD data leads to disagreement.
- Information-Theoretic Connection: The proposed disagreement score is shown to be closely related to information-theoretic measures like the effective sample size and Kullback-Leibler divergence. This provides a principled justification for the approach and links it to active learning principles.
- Latent Space OoD is Critical: The paper highlights that detecting outliers in the latent space is an important, yet under-addressed, problem, particularly for applications like Bayesian optimization in complex domains.
Key Results
The proposed BVAE methods (both variants) significantly outperform existing state-of-the-art unsupervised OoD detection methods on standard benchmarks.
- Input Space OoD Detection:
- On the FashionMNIST vs. MNIST benchmark, BVAE2 achieved an AUROC of 0.921 and AUPRC of 0.907, outperforming the best baseline (LLR) which achieved 0.617 and 0.613 respectively.
- On the SVHN vs. CIFAR10 benchmark, BVAE2 achieved an AUROC of 0.814 and AUPRC of 0.799, again outperforming baselines.
- The paper also shows that the BVAE2 score clearly separates in-distribution and OoD data better than standard log-likelihoods, as visualized in histograms.
- Latent Space OoD Detection:
- On a custom protocol for latent space OoD detection, the proposed method significantly outperformed two baselines (Annulus and qz).
Limitations and Future Work
- Computational Cost: While the paper states that SG-MCMC is not significantly more expensive than SGD, inferring a posterior distribution over parameters is inherently more computationally intensive than fitting point estimates.
- Dataset Similarity: The paper notes that BVAE2 (with a distribution over encoders) is particularly beneficial when in-distribution and OoD data are very distinct. When datasets are more similar (e.g., FashionMNIST held-out classes), a fixed encoder (BVAE1) might generalize better.
- Future Work: The authors suggest exploring extensions to other approximate inference techniques (like variational inference) and other deep generative models (e.g., flow-based or auto-regressive models). They also emphasize the need for further development of benchmarks and methods for latent space OoD detection.
Summary updated