On the Out-of-distribution Generalization of Probabilistic Image Modelling

Mingtian Zhang, Andi Zhang, Steven McDonagh

TL;DR

Deep generative models often fail at out-of-distribution (OOD) detection because their likelihood scores are dominated by low-level local textures shared across almost all images. This paper introduces a Local Autoregressive model that isolates these local features, enabling a "likelihood ratio" approach that achieves state-of-the-art unsupervised OOD detection and powers NeLLoC, a tiny, fast, and "universal" lossless image compressor.

What Problem Does This Paper Address?

In probabilistic machine learning, we expect a model trained on one dataset (e.g., FashionMNIST) to assign lower likelihoods to data from a completely different distribution (e.g., MNIST). However, researchers have observed a "likelihood paradox": models often assign higher densities to OOD data. This makes standard likelihood-based OOD detection unreliable.

Histogram demonstrating the likelihood paradox, where OOD data (MNIST) receives higher likelihood scores than in-distribution data (FMNIST).

The authors argue this happens because standard models (like PixelCNN) are "distracted" by local pixel correlations—low-level features like smooth gradients or simple textures—that are common to all images. These local features dominate the likelihood calculation, masking the global "semantic" features that actually define a specific dataset.

Additionally, traditional neural lossless compressors are often "brittle"—they perform poorly if the test image comes from a different distribution than the training set. The authors seek a way to build a "universal" compressor that generalizes better across diverse image types.

Methods

The core innovation is the Local Autoregressive Model ($p_l$).

Illustration of the Local Autoregressive Model, where a pixel's prediction depends only on a restricted local neighborhood.
  • Local vs. Full: While a "full" autoregressive model ($p_f$) allows a pixel to depend on all previously seen pixels in an image, the local model restricts this dependency to a small, fixed "horizon" $h$ (e.g., a $7 \times 7$ neighborhood).
  • Isolating Semantics: The authors hypothesize that the full model can be decomposed into a product of a local expert and a non-local (semantic) expert: $p_f(x) \propto p_l(x) \cdot p_{nl}(x)$.
  • OOD Detection Score: By rearranging this, they define a non-local score: $\hat{p}_{nl}(x) = \frac{p_f(x)}{p_l(x)}$. By dividing out the "local" likelihood, they cancel out the common textures and isolate the semantic signal, which is much more effective for OOD detection.
  • NeLLoC (Neural Local Lossless Compressor): They use the local model as the backbone for a compressor. Because local features are relatively consistent across different types of images, a local model trained on one dataset generalizes remarkably well to others. They also introduce a Discretized Logistic-Uniform mixture distribution to ensure the numerical stability required for exact lossless compression.

Datasets

The authors evaluated their methods on several standard benchmarks:

  • Grayscale: FashionMNIST (In-distribution) vs. MNIST, KMNIST, and OMNIGLOT (OOD).
  • Color: CIFAR10 (In-distribution) vs. SVHN and CelebA (OOD).
  • Compression Benchmarks: ImageNet32, ImageNet64, and full-resolution ImageNet.

Key Insights and Ideas

  • The "Local Dominance" Hypothesis: The most surprising insight is that local features don't just exist; they dominate the likelihood. A model that only looks at a $7 \times 7$ neighborhood can achieve nearly the same OOD likelihood as a model looking at the whole image.
  • Generalization through Limitation: By intentionally limiting the model's receptive field, the authors created a more "universal" tool. Because the local structure of a cat's fur isn't fundamentally different from the local structure of a brick wall, the local model doesn't "overfit" to the global semantics of the training set.
  • Computational Efficiency: Restricting the horizon reduces complexity from $O(N^2)$ to $O(h^2)$. This allows NeLLoC to run significantly faster than global neural compressors, making CPU-based neural decompression feasible.

Key Results

  • OOD Detection: Their method achieved a perfect 1.000 AUROC on FashionMNIST vs. MNIST and Omniglot, outperforming complex ensemble methods (like WAIC) and methods that require additional OOD data or labels.
  • Compression Performance: NeLLoC achieved state-of-the-art compression rates. For example, when trained on CIFAR10 and tested on the much larger ImageNet, it outperformed traditional codecs like PNG, WebP, and JPEG2000.
  • Model Size: NeLLoC is incredibly compact. While some neural compressors (like IDF) require over 200MB of parameters, NeLLoC achieves competitive results with just 2.75MB, making it suitable for edge devices.
  • Speed: Using an interleaved Asymmetric Numeral System (iANS), NeLLoC can decompress a CIFAR10 image in under 0.1 seconds on a CPU.

Limitations and Future Work

  • The PoE Assumption: The decomposition of the full model into a simple product of local and non-local experts is an approximation. A more mathematically rigorous definition of "non-local" features remains an open challenge.
  • Speed vs. Traditional Codecs: While fast for a neural model, NeLLoC is still slower than highly optimized non-neural codecs like standard JPEG.
  • Beyond Images: The authors suggest that this "local vs. global" framework could be extended to other high-dimensional data like audio or text, where local patterns (like phonemes or n-grams) might similarly dominate likelihoods.

Summary updated

BibTeX
@inproceedings{zhang2021out,
  author = {Mingtian Zhang and Andi Zhang and Steven McDonagh},
  title = {{On the Out-of-distribution Generalization of Probabilistic Image Modelling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=fMbF3bbyAY},
}
Figure