Skip to main content
QUICK REVIEW

[Paper Review] Back to the Basics: Revisiting Out-of-Distribution Detection Baselines

Johnson Kuan, Jonas Mueller|arXiv (Cornell University)|Jul 7, 2022
Adversarial Robustness in Machine LearningComputer Science13 citations
TL;DR

This paper revisits simple, model-agnostic out-of-distribution (OOD) detection methods and demonstrates that leveraging learned image representations via K-nearest neighbors (KNN) distance significantly outperforms prediction-only baselines like Maximum Softmax Probability (MSP). The key contribution is advocating for a dead-simple KNN-based OOD detection method using embedding space distances, which achieves state-of-the-art performance across ResNet-50 and Swin Transformer models on standard benchmarks.

ABSTRACT

We study simple methods for out-of-distribution (OOD) image detection that are compatible with any already trained classifier, relying on only its predictions or learned representations. Evaluating the OOD detection performance of various methods when utilized with ResNet-50 and Swin Transformer models, we find methods that solely consider the model's predictions can be easily outperformed by also considering the learned representations. Based on our analysis, we advocate for a dead-simple approach that has been neglected in other studies: simply flag as OOD images whose average distance to their K nearest neighbors is large (in the representation space of an image classifier trained on the in-distribution data).

Motivation & Objective

  • To evaluate the performance of simple, model-agnostic OOD detection methods that rely only on predictions or learned representations from a pre-trained classifier.
  • To investigate whether methods based solely on model predictions (e.g., MSP, entropy) are sufficient or if incorporating learned representations improves OOD detection.
  • To identify and advocate for a simple, interpretable, and highly effective OOD detection method that is compatible with any trained classifier.
  • To challenge the assumption that complex generative models are necessary for reliable OOD detection, showing that basic KNN in representation space performs competitively.

Proposed method

  • Proposes a KNN-based OOD detection method that computes the average distance from an input image to its K nearest neighbors in the embedding space of a pre-trained classifier.
  • Uses the learned representations (embeddings) from a classifier trained on in-distribution data as the feature space for computing local density estimates.
  • Employs the average KNN distance as an OOD score: larger distances indicate higher likelihood of being out-of-distribution.
  • Extends the method to include both distance-only and distance-prediction variants (KNN_DistPred and KNN_Prediction), where predictions of neighbors are also considered.
  • Applies the method to ResNet-50 and Swin Transformer models, evaluating on standard OOD benchmarks like CIFAR-10 vs. CIFAR-100, MNIST vs. Fashion-MNIST.
  • Uses AUROC as the primary evaluation metric across multiple in-distribution and out-of-distribution dataset pairs.

Experimental results

Research questions

  • RQ1Can a simple KNN-based method using only the embedding space of a pre-trained classifier outperform established baselines like MSP and entropy in OOD detection?
  • RQ2Does incorporating learned representations (embeddings) significantly improve OOD detection performance compared to relying solely on model predictions?
  • RQ3How does the performance of the proposed KNN method vary with different values of K across diverse model architectures and datasets?
  • RQ4Is the KNN-based method robust and effective across different combinations of in-distribution and out-of-distribution datasets, including those with significant domain shifts?
  • RQ5Why does the Maximum Softmax Probability (MSP), despite being a poor proxy for epistemic uncertainty, still perform well in OOD detection, and can simpler representation-based methods surpass it?

Key findings

  • The KNN-based OOD detection method using average distance to K nearest neighbors in the embedding space achieves state-of-the-art AUROC scores on both ResNet-50 and Swin Transformer models across all tested datasets.
  • On the Swin Transformer, the KNN Distance method achieves AUROC of 0.9917 on CIFAR-10 vs. CIFAR-100 and 0.9989 on MNIST vs. Roman Numerals, outperforming MSP (0.9689) and Entropy (0.9690).
  • On ResNet-50, the KNN Distance method achieves AUROC of 0.9390 on CIFAR-10 vs. CIFAR-100 and 1.0000 on MNIST vs. Roman Numerals, surpassing MSP (0.9268) and Entropy (0.9318).
  • The method remains highly effective even with K=5, achieving AUROC >0.99 in multiple settings, and performance is stable across K=5 to K=100, indicating robustness to hyperparameter choice.
  • The KNN Distance method consistently outperforms more complex baselines like Mahalanobis distance, RMD, and Isolation Forest, especially on challenging OOD shifts.
  • The study demonstrates that simple, representation-based methods like KNN distance are not only effective but also more interpretable and practical than complex generative models, which require extensive tuning and are model-specific.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.