Source-linked AI summary

Likelihood Regret: An Out-of-Distribution Detection Score For Variational Auto-encoder

Zhisheng Xiao, Qing Yan, Yali Amit

arXiv:2003.02977v3cs.LGcs.CVstat.ML

TL;DR

Likelihood-based OOD detection can fail because generative models assign high likelihoods to some OOD samples, and existing scores may be ineffective for VAEs. The paper proposes Likelihood Regret, which compares individually optimized and population-level likelihood configurations, and reports the best overall VAE OOD detection performance. Its main practical limitation is higher per-image computation than competing methods, although the measured overhead is acceptable in the experiments.

  • Problem

    Generative models can assign spuriously high likelihoods to OOD samples, while existing likelihood-based OOD scores may fail on VAEs.

  • Method

    Likelihood Regret measures the log-likelihood improvement from individually optimizing a sample’s model configuration over the configuration optimized for population likelihood.

  • Results

    Likelihood Regret obtains good OOD detection across evaluated tasks and achieves the best overall performance, remaining close to the best results where it does not rank first.

  • Takeaways & Limitations

    Likelihood Regret provides an effective OOD score for VAEs across the evaluated tasks without the failure cases observed for competing methods.

  • Takeaways & Limitations

    Likelihood Regret requires two likelihood estimations and optimization iterations per test image, making it slower than competing methods.

Abstract

from arXiv · show

Deep probabilistic generative models enable modeling the likelihoods of very high dimensional data. An important application of generative modeling should be the ability to detect out-of-distribution (OOD) samples by setting a threshold on the likelihood. However, some recent studies show that probabilistic generative models can, in some cases, assign higher likelihoods on certain types of OOD samples, making the OOD detection rules based on likelihood threshold problematic. To address this issue, several OOD detection methods have been proposed for deep generative models. In this paper, we make the observation that many of these methods fail when applied to generative models based on Variational Auto-encoders (VAE). As an alternative, we propose Likelihood Regret, an efficient OOD score for VAEs. We benchmark our proposed method over existing approaches, and empirical results suggest that our method obtains the best overall OOD detection performances when applied to VAEs.

1 Introduction

Deep generative models can evaluate likelihoods for complex data, motivating likelihood-based OOD detection. However, generative-model likelihoods may fail to distinguish training data from some obvious OOD samples, and existing likelihood-based scores are less effective for VAEs.

  • Existing OOD detection methods developed for deep classifiers do not apply directly to unsupervised generative models.The introduction identifies this gap as a limitation of classifier-based approaches.
  • Deep probabilistic generative models can model very high-dimensional data, evaluate input likelihoods, and generate realistic samples.These capabilities suggest that generative models approximate training-data distributions and could support OOD detection.
  • Likelihood-based OOD detection is problematic because current generative models can assign high likelihoods to some OOD samples.This counterintuitive behavior challenges the validity of unsupervised OOD detection using generative models.
  • Likelihood-based scores that work well for flow-based and autoregressive models can be much less effective for VAEs.The paper therefore motivates a new score specifically for VAE-based OOD detection.

2 Background

VAEs model observations through latent variables and neural-network parameterized distributions, training an approximate posterior and decoder with an ELBO objective. The paper’s background shows that likelihood misalignment persists for VAEs, even though they can reconstruct OOD data well.

  • 2.1 Variational Auto-Encoder: A VAE models an observed variable x using a latent variable z, prior p(z), and conditional distribution pθ(x|z).Its marginal likelihood pθ(x) integrates over the latent variable.
  • 2.1 Variational Auto-Encoder: Because direct likelihood computation is intractable in high dimensions, variational inference derives the evidence lower bound, or ELBO.The variational posterior qφ(z|x) approximates the true posterior pθ(z|x).
  • 2.1 Variational Auto-Encoder: The VAE is trained by maximizing ELBO over training data, with encoder parameters φ and decoder parameters θ.Exact log likelihood is typically estimated using an importance-weighted lower bound.
  • 2.1 Variational Auto-Encoder: The experiments use a factorial 256-way categorical decoding distribution for each pixel of 8-bit images.The same data distribution is assumed by PixelCNN in the paper’s comparisons.
  • 2.2 Problems with OOD Detection using Probabilistic Generative Models: In the OOD setting, samples are considered out of distribution when they have low density under the underlying data distribution.Likelihood-based detection would therefore classify low-likelihood samples as OOD, but the paper tests this assumption against VAE behavior.
  • 2.2 Problems with OOD Detection using Probabilistic Generative Models: VAEs may assign spuriously high likelihood to OOD samples and reconstruct both in-distribution and OOD images surprisingly well.These observations make likelihood an extremely unreliable OOD detector for VAEs.

3 Related Work

Prior work explored alternative OOD scores and specialized generative architectures, but their effectiveness does not consistently transfer to VAEs. Related methods also face computational or single-sample detection limitations.

  • Energy-based models can reduce likelihood misalignment, but in-distribution and OOD test likelihoods still overlap significantly.Bidirectional-inference VAEs with deep latent hierarchies only slightly alleviate misalignment and incur an associated cost.
  • Ensembles exploit higher variance of OOD likelihood estimates, but training multiple models can be computationally expensive.Other methods use typicality or batch normalization to construct alternative OOD scores.
  • Table 1 compares average BPD across datasets for VAE, Glow, and PixelCNN trained on Fashion MNIST and CIFAR-10.The comparison supports analysis of why OOD scores may behave differently across generative-model families.
  • Typicality and batch-normalization scores can determine whether a batch is anomalous, but are limited for detecting individual samples.Single-sample detection is the usual requirement in practical OOD detection.
  • Likelihood-ratio methods compare a model with a background model, while input-complexity methods offset likelihood bias using a complexity factor.These approaches are presented as closely related alternatives to the paper’s proposed score.
  • Earlier VAE anomaly-detection methods often relied on the assumption that VAEs reconstruct OOD samples poorly, an assumption later shown false in many cases.Other work combines reconstruction loss with Mahalanobis distance in latent space.

4 Likelihood Regret for OOD Detection using VAEs

Likelihood-based OOD scores that work well for flow-based and autoregressive models can be less effective for VAEs because their in-distribution and OOD likelihoods are less separated. Likelihood Regret addresses this by optimizing the variational posterior for each test sample while keeping the decoder fixed, then measuring the resulting likelihood improvement.

  • Motivation: VAE likelihoods show a much smaller range across datasets than Glow and PixelCNN, leaving in-distribution and OOD samples less separated.This smaller likelihood gap partly explains why existing generative-model OOD scores are less effective for VAEs.
  • Motivation: Current likelihood-based OOD scores can perform impressively on flow-based and autoregressive models but are much less effective for VAEs.The paper therefore motivates a score designed specifically for VAE likelihood behavior.
  • Likelihood Regret: Likelihood Regret measures the log-likelihood improvement from an individually optimized model configuration relative to the configuration maximizing population likelihood.For in-distribution samples this improvement should be relatively small, whereas OOD samples can produce larger improvements.
  • Likelihood Regret: The VAE bottleneck provides regularization by restricting single-sample optimization to the variational-posterior parameters, reducing the risk of overfitting that sample.The optimized likelihood is compared with the original VAE likelihood to obtain the score.
  • Likelihood Regret: The method fixes the trained decoder and optimizes each sample’s variational-posterior statistics, initialized from the trained encoder, using the ELBO objective.The implementation can optimize the posterior statistics directly or optimize encoder parameters initialized at their trained values.
  • Likelihood Regret: Likelihood Regret can also be viewed as the log ratio between likelihood under the individually optimized posterior and likelihood under the VAE trained on the training set.This interpretation connects the score to other likelihood-ratio-based OOD methods.

5 Results

Experiments show that Likelihood Regret (LR) separates OOD from in-distribution samples for VAEs and generally outperforms competing likelihood-based scores, while remaining effective across VAE settings.

  • Proof-of-concept experiments: LR assigns higher scores to OOD samples in Fashion-MNIST versus MNIST and CIFAR-10 versus SVHN proof-of-concept experiments.These experiments use VAEs trained on Fashion-MNIST or CIFAR-10 and evaluate 1,000 in-distribution and OOD test samples.
  • Proof-of-concept experiments: 0.165 to 0.999 and 0.161 to 0.876 are the AUC-ROC improvements from log likelihood to LR on the two proof-of-concept tasks.Log likelihood performs below random guessing, whereas LR achieves strong OOD detection.
  • Quantitative comparison: LR obtains near-optimal AUC-ROC across experiments except CIFAR-10 versus CelebA and CIFAR-10 versus LSUN, which are difficult texture-similarity cases.The authors report that encoder optimization performs slightly better than directly optimizing latent variables.
  • Quantitative comparison: Competing scores exhibit task-specific failures, including likelihood ratio at 0.28 for SVHN versus CIFAR-10 and input-complexity scores near 0 for noise versus CIFAR-10.Latent Mahalanobis distance also performs poorly on almost all OOD datasets when CIFAR-10 is in-distribution.
  • Quantitative comparison: LR achieves the best overall OOD detection performance and remains effective across tasks where competing methods fail.The authors attribute some competitor failures to VAE-specific likelihood and complexity behavior, including weaker pixel-level modeling.
  • Robustness and runtime: LR behaves consistently across β-VAE values and is robust to VAE capacity, although larger capacity can slightly reduce AUC-ROC.The method requires two likelihood estimations and optimization iterations, averaging less than 0.3 seconds per test image in the reported experiments.

6 Conclusion

The paper finds that existing generative-model OOD scores do not transfer reliably to VAEs, while Likelihood Regret performs effectively across evaluated tasks.

  • Current state-of-the-art OOD scores for generative models may not apply effectively to VAEs.
  • Likelihood Regret is proposed as an OOD score designed for VAEs.
  • Likelihood Regret achieves effective OOD detection on all evaluated tasks.
  • The authors suggest Likelihood Regret could extend to other generative models when a good optimizable model configuration is defined.

Broader Impact

OOD detection matters for systems making critical decisions, but anomalous cases can still fool detection algorithms, so these systems should not be completely trusted.

  • OOD detection is important for systems used in medical diagnosis, factory manufacturing, and autonomous driving.
  • Anomalous cases can fool algorithmic anomaly-detection systems.
  • The paper cautions against completely trusting imperfect anomaly-detection algorithms.

A.1 Datasets

The experiments use public image datasets, synthetic Noise and Constant images, and VAEs trained mainly on Fashion-MNIST and CIFAR-10 under standardized preprocessing and model settings.

  • The experiments use MNIST, Fashion-MNIST, KMNIST, notMNIST, CIFAR-10, CIFAR-100, SVHN, CelebA, and LSUN.
  • Synthetic OOD images comprise random-pixel Noise images and Constant images with one sampled value per channel.
  • VAEs are trained mainly on Fashion-MNIST and CIFAR-10, while other datasets serve as test data using available test partitions or random samples.
  • All images are resized to 32 × 32, with channel conversion used when testing across grayscale and color datasets.
  • Quantitative metrics use 5000 randomly chosen in-distribution images and 5000 randomly chosen OOD images.
  • The VAE models follow a DCGAN-based structure, with nz = 100 and dataset-specific nf and nc settings.
  • Likelihood Regret is computed by optimizing either the whole encoder or only the posterior mean and variance.
  • Competing baselines include input-complexity-adjusted likelihood, likelihood ratio with a background model, and latent Mahalanobis distance.

B Additional Quantitative results: AUPRC and FPR80

The appendix reports AUCPRC and FPR80 comparisons for Likelihood Regret and other OOD detection scores across datasets.

  • Table 6 reports AUCPRC for Likelihood Regret and other OOD detection scores on different datasets.
  • Table 7 reports FPR80 for Likelihood Regret and other OOD detection scores on different datasets.

C Results of Model Trained on SVHN

On SVHN-trained VAEs, Likelihood Regret performs well across tasks, while competing scores show task-specific weaknesses. Additional experiments indicate input-complexity adjustment can also fail beyond VAEs.

  • Likelihood Regret achieves good performance on all SVHN-trained VAE tasks.
  • Likelihood itself works well on most SVHN tasks, while every method performs nearly perfectly for MNIST-trained VAEs.
  • Competing OOD scores exhibit systematic issues on VAEs, including weak performance for SVHN versus CIFAR-10 and likelihood-ratio failures for CIFAR-10 versus Constant.
  • Input complexity adjusted likelihood obtains AUCROC 0.633 for MNIST versus Fashion MNIST and 0.518 for SVHN versus CIFAR-10 on Glow.
  • VAE reconstructions can look strong for both in-distribution and OOD data, although optimized posterior reconstructions visibly improve MNIST examples.
  • Figure 6 compares originals, standard VAE reconstructions, and reconstructions using the optimized encoder for Fashion MNIST and CIFAR-10.

H Randomly Generated Samples

VAEs generate recognizable in-distribution samples despite blurry, slightly noisy outputs. The section also presents random samples and capacity-related evaluation context.

  • Randomly generated VAE samples are blurry and slightly noisy because of the cross-entropy loss.
  • The generated samples’ semantics suggest that the VAEs model in-distribution data well.
  • Figure 9 presents randomly generated samples from the VAEs.
Loading 2003.02977v3…