Towards In-distribution Compatibility in Out-of-distribution Detection

Boxi Wu, Jie Jiang, Haidong Ren, Zifan Du, Wenxiao Wang, Zhifeng Li, Deng Cai, Xiaofei He, Binbin Lin, Wei Liu

TL;DR

The paper introduces ICE (In-distribution Compatible outlier Exposure), a novel framework that solves the common trade-off where training a model to detect out-of-distribution (OOD) data hurts its primary classification accuracy. By redesigning the model's final layer and loss function to respect the probabilistic structure of features, ICE achieves state-of-the-art OOD detection while actually improving standard in-distribution accuracy.

What Problem Does This Paper Address?

Deep neural networks are notoriously overconfident, often assigning high-confidence scores to "out-of-distribution" (OOD) data—inputs that don't belong to any of the classes the model was trained on. To fix this, researchers often use "Outlier Exposure" (OE), where the model is explicitly trained on an auxiliary dataset of outliers to learn what "none of the above" looks like.

However, the authors identify a significant drawback: existing OE methods often degrade the model's performance on its original task (in-distribution accuracy). They pinpoint three core reasons for this "in-distribution incompatibility":

  1. Contradictory Gradients: The math used to penalize outliers sometimes forces the model to reduce confidence in the correct class for normal data.
  2. False Likelihood: Standard models use "logits" (raw output scores) as a proxy for how likely a sample is to belong to a class. The authors show that an outlier can be far from all classes but still have a high logit value.
  3. Distribution Shift: Training on outliers can inadvertently "squeeze" or shift the features of normal data, making them less distinct and harder to classify.
ICE outperforms previous methods on both accuracy and OOD detection.

Methods

The authors propose two major architectural changes to create ICE:

  • Modified Top-Design: They replace the standard linear final layer with a class-conditional Gaussian model. Instead of simple dot products, the model calculates scores based on the Mahalanobis distance to learned class centers. This ensures that the model's internal "confidence" is tied to how close a sample is to a known cluster in feature space.
  • Probabilistic Loss Function: They derive a new loss function based on Maximum Likelihood Estimation (MLE).
  • For in-distribution samples, the loss "drags" features toward their respective class centers.
  • For outliers, the loss "pushes" them away from the nearest class centers.

Crucially, this design avoids contradictory gradients because the outlier penalty never tries to suppress the ground-truth signal of in-distribution data.

Datasets

The researchers evaluated their method using standard computer vision benchmarks:

  • In-distribution (ID): CIFAR-10 and CIFAR-100.
  • Out-of-distribution (OOD) for testing: SVHN, Textures, Places365, LSUN, and iSUN.
  • Auxiliary Outliers for training: The "80 Million Tiny Images" dataset (a common choice for OE research).

Key Insights and Ideas

  • Logits $\neq$ Likelihood: Figure 2 in the paper illustrates a critical "aha moment": a point can be much further from a class center (lower likelihood) but still have a higher logit value because of the orientation of the decision boundary. By switching to distance-based scoring, ICE fixes this fundamental flaw.
Comparison between logit values and class likelihood. Logits can be misleading for OOD samples.
  • Push vs. Pull: Standard OE methods often try to push outliers toward the "center" of the feature space, which can cause them to mix with ID features. ICE instead pushes outliers away from the ID clusters, maintaining a "moat" that prevents distribution shift.
Figure 3: The distribution shift effect is caused by different methods. We plot feature distribution for each step of SGD opti- mization. Standard Outlier Exposure shifts outliers to the center of space, during which the in- and out-of-distribution samples are mixed. On the other hand, ICE pushes outliers away from the class center and does not suffer from distribution shift.

Key Results

ICE consistently outperformed baseline methods (like standard OE and Energy-based models) across various metrics:

  • Improved Accuracy: On CIFAR-10, ICE improved in-distribution accuracy from 95.11% to 96.38%, whereas previous OE methods often saw accuracy drop below the baseline.
  • Superior OOD Detection: In the challenging "CIFAR-10 vs CIFAR-100" task, ICE reduced the False Positive Rate (FPR95) to 22.36%, a significant improvement over the previous state-of-the-art (~26%).
  • Better Feature Separation: t-SNE visualizations show that ICE produces much tighter, more distinct clusters for ID classes while keeping outliers clearly separated.
Figure 4: Feature visualization with t-SNE algorithm. We present three OE methods and Plain Training. ICE learns compact and discriminating features. ▲represents OOD examples (CIFAR100), and the rest examples are in-distribution (CIFAR10).

Limitations and Future Work

The authors note that while ICE is highly effective, it relies on the assumption that features in the penultimate layer follow a Gaussian distribution. While this is common in deep learning, it might not hold for all architectures or data types. Future work could involve exploring more complex distribution models (beyond simple Gaussians) or applying these "compatibility" principles to other domains like Natural Language Processing.

Summary updated

BibTeX
@misc{wu2022towards,
  author = {Boxi Wu and Jie Jiang and Haidong Ren and Zifan Du and Wenxiao Wang and Zhifeng Li and Deng Cai and Xiaofei He and Binbin Lin and Wei Liu},
  title = {{Towards In-distribution Compatibility in Out-of-distribution Detection}},
  year = {2022},
  eprint = {2208.13433},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2208.13433},
}
Figure