Prototype-based Optimal Transport for Out-of-Distribution Detection

Ao Ke, Wenlong Chen, Chuanwen Feng, Yukun Cao, Xike Xie, S. Kevin Zhou, Lei Feng · DOI

Introduction

Deep Neural Networks (DNNs) are notoriously prone to overconfidence, often assigning high-probability scores to inputs they have never encountered during training. This phenomenon, known as Out-of-Distribution (OOD) detection failure, is a critical bottleneck for deploying AI in safety-sensitive applications like autonomous driving or medical diagnosis.

The primary challenge lies in distinguishing between In-Distribution (ID) data and "near-OOD" data—samples that share semantic or visual similarities with the training set but belong to different classes. While "far-OOD" data (e.g., MNIST digits vs. ImageNet objects) is relatively easy to identify, near-OOD samples often reside in the ambiguous "gray areas" of a model's latent space. Existing detection methods typically rely on simple distance metrics or density estimations that fail to capture the nuanced geometric relationships between these distributions.

Methodology: POT

To address these challenges, this paper introduces POT (Prototype-based Optimal Transport), a post-hoc detection framework that leverages the mathematical principles of Optimal Transport (OT) to quantify distributional shifts.

1. Prototype-based Optimal Transport (OT)

Rather than comparing a test input to every individual training sample—a computationally prohibitive task—POT represents each ID class with a prototype, defined as the average feature representation of that class. By treating the test batch and the set of ID prototypes as two discrete distributions, the method employs the Sinkhorn-Knopp algorithm to calculate the "transport cost" required to map one to the other.

Overview of Prototype-based Optimal Transport (POT) and the Transport Cost Matrix.

Unlike standard Euclidean distance, OT is "geometrically aware." It considers the entire distribution of prototypes, allowing the model to determine how much a specific test point contributes to the overall distributional shift. The resulting row sums of the transport cost matrix serve as the initial OOD scores.

2. Virtual Outlier Generation via Linear Extrapolation

To sharpen the decision boundary, POT introduces "virtual outliers." By calculating the average representation of the current test batch ($M$) and extrapolating away from the ID prototypes ($M_{in}$), the method generates synthetic OOD points ($M_{out}$).

Generation of virtual outliers via linear extrapolation from ID prototypes.

A "contrastive" transport cost is then computed by comparing the cost to ID prototypes against the cost to these virtual outliers. This contrastive approach significantly enhances sensitivity to OOD samples that might otherwise be misclassified as ID due to their proximity to known clusters.

Experimental Results

The authors evaluated POT using the OpenOOD benchmarking framework across multiple architectures, including ResNet-18, ResNet-50, and ViT-b16, on datasets such as CIFAR-100 and ImageNet-1k.

  • State-of-the-Art Performance: POT outperformed 21 previous OOD detection methods across various benchmarks.
  • Near-OOD Mastery: On the challenging CIFAR-100 benchmark, POT reduced the FPR95 (False Positive Rate at a 95% True Positive Rate) by 25.6% compared to previous leading baselines.
  • Data-Free Success: In scenarios where training data was completely unavailable, POT utilized the weights of the final classification layer as "proxy" prototypes. In this setting, it outperformed its closest robust competitor by a massive 22.5% margin in FPR95.
  • Pluggability: As a post-hoc method, POT is "training-agnostic" and can be combined with other OOD-specific training techniques (e.g., RotPred) to further boost performance.

Discussion and Limitations

While POT offers a powerful and scalable solution for OOD detection, it is subject to certain constraints. The method's effectiveness is partially dependent on the test batch size. While it remains superior to baselines at small batch sizes (e.g., 32), its full potential is realized with larger batches (e.g., 512), which provide a more stable estimation for virtual outlier generation. Additionally, the method introduces hyperparameters such as the extrapolation coefficient ($\omega$) and the Sinkhorn regularization term ($\lambda$), which may require domain-specific tuning. Despite these factors, POT represents a significant step forward in making DNNs more reliable in open-world environments.

Summary updated

BibTeX
@inproceedings{ke2025prototype,
  author = {Ao Ke and Wenlong Chen and Chuanwen Feng and Yukun Cao and Xike Xie and S. Kevin Zhou and Lei Feng},
  title = {{Prototype-based Optimal Transport for Out-of-Distribution Detection}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/336},
}
Figure