NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Class Relevance Learning For Out-of-distribution Detection

Butian Xiong, Liguang Zhou, Tin Lun Lam, Yangsheng XuarXiv 2024 · DOI

Introduction

In real-world deployments, image classifiers frequently encounter Out-of-Distribution (OOD) samples—inputs from categories not present in the training set. While a robust system should flag these as unknown, standard models often assign high confidence to OOD samples that share superficial features with known classes. For example, a model might misidentify a parking lot as a garage because both contain cars.

Traditional detection methods, such as Max Logits or Maximum Softmax Probability, are often insufficient because they focus solely on the "winning" class, ignoring the rich structural information present in the full probability distribution. To address these limitations, we introduce Class Relevance Learning (CRL), a post-processing framework that analyzes the "class relevance matrix" to identify anomalies by examining how a sample relates to all known categories simultaneously.

Methodology: Class Relevance Learning (CRL)

The CRL framework: From input samples to the final Class Relevance Score via prototype calculation and relevance matrix analysis.

The CRL framework consists of three primary stages:

  1. Relevance Matrix Construction: For each known class, a "prototype" is calculated as the average softmax probability distribution across all training samples in that class. This results in an $N \times N$ matrix ($P_{crm}$) capturing typical inter-class relationships.
  2. Relevance Score Calculation: At inference, the model generates a probability distribution for a test sample. We identify the most likely "pseudo-class" and measure the log-sum distance between the sample's distribution and the corresponding class prototype.
  3. Hybrid Scoring: The final OOD score ($P_{cf}$) is a weighted combination of the traditional Max Logit score and the new Class Relevance Score. This approach leverages both raw confidence and structural similarity.

Critically, CRL is a post-processing method. It does not require retraining the original classification model, making it easy to integrate into existing pipelines.

Experimental Results

We evaluated CRL using a ResNet18 backbone, with CIFAR10 as the In-Distribution (ID) dataset. We tested against both "Near-OOD" (e.g., CIFAR100, TinyImageNet) and "Far-OOD" (e.g., MNIST, Places365) datasets.

Distribution of confidence scores for In-Distribution (ID) vs. Out-of-Distribution (OOD - TinyImageNet) samples, demonstrating the effective separation achieved by the CRL method.

CRL consistently outperforms state-of-the-art methods like ODIN, DICE, and SHE. In the challenging CIFAR100 Near-OOD benchmark, CRL achieved a False Positive Rate (FPR95) of 42.34%, a significant improvement over ODIN (73.89%) and DICE (68.81%). Furthermore, in Far-OOD scenarios, CRL maintained a high AUROC of 91.48%.

Key Insights and Discussion

The success of CRL stems from the observation that while OOD samples may mimic a single known class, their relationship to the broader set of classes is typically anomalous. By statistically modeling "correct" inter-class relationships, CRL provides a finer filter for detection. This highlights the importance of the "tail" of the probability distribution, which contains vital structural information often discarded by standard methods.

While CRL introduces minor computational overhead and requires hyperparameter tuning to balance raw confidence and relevance scores, its superior performance—especially in difficult Near-OOD cases—makes it a compelling choice for safety-critical machine learning applications. Future work will explore integrating relevance learning directly into the training phase or exploring more complex distance metrics.

Summary updated

BibTeX
@misc{xiong2024class,
  author = {Butian Xiong and Liguang Zhou and Tin Lun Lam and Yangsheng Xu},
  title = {{Class Relevance Learning For Out-of-distribution Detection}},
  year = {2024},
  eprint = {2401.01021},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.01021},
}
Figure