A Simple Test-Time Method for Out-of-Distribution Detection

Ke Fan, Yikai Wang, Qian Yu, Da Li, Yanwei FuarXiv 2022 · DOI

Abstract

Deep neural networks frequently exhibit overconfidence when encountering out-of-distribution (OOD) data, a significant hurdle for safe real-world deployment. This paper introduces ETLT (Embarrassingly simple Test-time Linear Training), a method that leverages a "surprisingly linear" relationship between high-level features and standard OOD scores. By fitting a linear regression model to these features at test-time, ETLT rectifies noisy predictions, reducing error rates (FPR95) on CIFAR-10 from over 51% to just 12%.

Introduction

The reliability of AI systems in domains like autonomous driving or medical diagnosis depends on their ability to identify samples that fall outside their training distribution. Existing OOD detectors, such as those based on Maximum Softmax Probability (MSP) or energy scores, often process images in isolation and produce sub-optimal, noisy results. This research explores a transductive approach, using the collective information within a batch of test images to achieve more precise OOD detection.

Methodology: ETLT

The core of ETLT is the observation that OOD scores from base detectors are roughly linearly correlated with the image features extracted by a model's penultimate layer.

Linear fitting and decision boundaries for various OOD datasets.

The authors propose three variants of the method:

  1. Direct Linear Regression (DLR): Solves a least-squares problem to map features ($z$) to base OOD scores ($\hat{s}$) within a test batch.
  2. Robust Linear Regression (RLR): Incorporates a sparse outlier variable to mitigate the impact of noisy base scores during fitting.
  3. Online DLR: An iterative version suitable for streaming data, maintaining efficiency regardless of batch size.

Analysis and Insights

A key insight of this work is that while OOD scoring functions are complex and non-linear, they behave like Generalized Linear Models (GLMs) relative to the feature space. This allows a simple linear layer to "smooth out" errors. Furthermore, the feature space of pre-trained models naturally clusters in-distribution (ID) and OOD data into regions that are nearly linearly separable, even without explicit OOD training.

Feature space separability between ImageNet (ID) and OOD datasets (iNaturalist, Places).

Experimental Results

ETLT was evaluated on standard benchmarks including CIFAR-10, CIFAR-100, and ImageNet-1k against various OOD sets like Textures, Places365, and iNaturalist.

  • Performance Gains: On CIFAR-10, ETLT improved the FPR95 of the MSP baseline from 51.37% to 12.30%. On ImageNet-1k, it reduced the average FPR95 from 76.96% to 46.83%.
  • Noise Robustness: In pure noise scenarios where standard detectors failed (near 100% FPR), ETLT brought the FPR down to as low as 0.01%.
  • Orthogonality: The method can be combined with other techniques like ReAct (feature clipping) for additive performance benefits.

Conclusion and Limitations

ETLT provides a simple yet powerful way to enhance OOD detection at test-time. However, it is batch-dependent and requires a sufficient number of ID samples (typically 20-40%) within the test batch to fit the regression accurately. Future research may explore non-linear refinements or applications in non-visual modalities.

Summary updated

BibTeX
@misc{fan2022simple,
  author = {Ke Fan and Yikai Wang and Qian Yu and Da Li and Yanwei Fu},
  title = {{A Simple Test-Time Method for Out-of-Distribution Detection}},
  year = {2022},
  eprint = {2207.08210},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2207.08210},
}
Figure