Detecting OOD Samples via Optimal Transport Scoring Function

Heng Gao, Zhuolin He, Jian Pu · DOI

TL;DR

This paper introduces OTOD, a novel post-hoc method for detecting Out-of-Distribution (OOD) samples in machine learning models. OTOD leverages optimal transport theory to create a scoring function that doesn't require additional training data, outperforming existing methods by effectively capturing geometric cues in network representations.

What Problem Does This Paper Address?

Deploying machine learning models in real-world scenarios requires them to reliably identify "unknown" or Out-of-Distribution (OOD) samples. When faced with data that differs from what they were trained on, models can produce untrustworthy predictions with high confidence. While many OOD detection algorithms exist, "post-hoc" methods are particularly attractive because they are model-agnostic and don't require retraining. However, existing post-hoc methods often struggle to capture the nuanced geometric relationships within the internal representations (features) learned by neural networks. This limitation can lead to them missing OOD samples that might be geometrically distinct but not easily separable by simpler statistical measures.

Methods

The core of OTOD is a novel scoring function based on optimal transport theory, specifically the Wasserstein-1 distance. This distance is a powerful tool for comparing probability distributions and can capture spatial discrepancies.

Here's a breakdown of their approach:

  • Optimal Transport Score Calculation: For each test sample, OTOD first extracts features from the penultimate layer of a pre-trained neural network. These features are then normalized. The Wasserstein-1 distance is used to measure the "distance" between the normalized feature distribution of the test sample and a reference distribution (represented by a mean vector and a zero vector, creating an "ensemble effect"). This distance forms the initial OOD score.
  • Multi-scale Information Integration: To improve performance, OTOD doesn't rely solely on features. It also incorporates information from the model's logits (raw output scores before softmax) and softmax probabilities. These are also normalized and used to calculate Wasserstein-1 distances, creating additional scores. The final OOD score is a weighted combination of these three scores (feature, logits, and softmax).
  • Temperature Scaling: Similar to the ODIN method, OTOD applies temperature scaling to the softmax probabilities. This technique can further amplify the differences between in-distribution and OOD samples, enhancing the detection performance.

Datasets

The paper evaluates OTOD on two common benchmarks:

  • CIFAR-10: Used for training.
  • CIFAR-100: Used for training and as an OOD dataset.

Additional OOD datasets used for evaluation include:

  • Tiny ImageNet (TIN)
  • MNIST
  • SVHN
  • Texture
  • Places365

Key Insights and Ideas

  • Optimal Transport for Geometric Cues: The key insight is that optimal transport distances are well-suited to capture the geometric structure of feature spaces, which simpler methods might miss. This allows OTOD to better distinguish between in-distribution and out-of-distribution samples based on their spatial relationships within the network's learned representations.
  • Multi-modal Scoring: Combining information from features, logits, and softmax probabilities significantly boosts OOD detection performance. This suggests that different layers and output stages of a neural network capture complementary information relevant to OOD detection.
  • Theoretical Guarantees: The paper provides theoretical guarantees for the feature-based component of OTOD, showing that it can detect pronounced distribution shifts. This adds a layer of mathematical rigor to their empirical findings.

Key Results

OTOD demonstrates superior performance across various OOD detection benchmarks:

  • CIFAR-10 Benchmark: OTOD outperforms the state-of-the-art method GEN by a significant margin, achieving 7.19% lower mean FPR@95 on CIFAR-10 with ResNet-18 and 12.51% lower with WideResNet-28.
  • CIFAR-100 Benchmark: OTOD achieves the best mean FPR@95 and competitive AUROC scores, outperforming KLM by 18.19% FPR@95 on average.
  • Ablation Studies: The results confirm that combining features, logits, and softmax probabilities leads to the best performance, with the feature-only approach showing a notable drop in AUROC compared to the full model.
  • Temperature Scaling: The analysis shows that temperature scaling is crucial for enhancing OOD detection, with an optimal range for the temperature parameter.

Limitations and Future Work

  • Computational Cost: While OTOD is a post-hoc method, calculating optimal transport distances can be computationally more intensive than simpler scoring functions, especially for high-dimensional feature spaces.
  • Hyperparameter Tuning: The performance of OTOD is sensitive to hyperparameters like temperature scaling, requiring careful tuning for optimal results.
  • Future Work: The authors suggest exploring more advanced optimal transport techniques and investigating how OTOD can be extended to other domains beyond image classification. They also mention the potential for further theoretical analysis of the integrated scoring function.

Summary updated

BibTeX
@inproceedings{gao2025detecting,
  author = {Heng Gao and Zhuolin He and Jian Pu},
  title = {{Detecting OOD Samples via Optimal Transport Scoring Function}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2025},
  doi = {10.1109/icassp49660.2025.10890502},
}
Figure