Long-Tailed Out-of-Distribution Detection via Normalized Outlier Distribution Adaptation

Wenjun Miao, Guansong Pang, Jin Zheng, Xiao Bai

TL;DR

Out-of-distribution (OOD) detection becomes notoriously difficult when in-distribution data is long-tailed, as models easily confuse rare "tail" classes with outliers. This paper introduces AdaptOD, a framework that balances training energy across imbalanced classes and dynamically adapts to true OOD data at test time without model retraining. By bridging the distribution gap between proxy training outliers and true test-time OOD data, AdaptOD achieves state-of-the-art detection performance.

What Problem Does This Paper Address?

Deep neural networks are famously overconfident, often misclassifying out-of-distribution (OOD) data—samples from unknown classes—as known in-distribution (ID) classes. To mitigate this, a popular approach is Outlier Exposure, where models are trained using auxiliary external datasets as "proxy" outliers.

However, a major gap remains: these proxy outliers rarely match the distribution of true OOD data encountered at test time. This distribution shift is severely exacerbated in Long-Tailed Recognition (LTR) scenarios, where a few "head" classes dominate the dataset and many "tail" classes have very few samples. Because the model becomes heavily biased toward head classes, standard energy-based OOD detectors underestimate tail-class confidence, leading them to mistake rare ID samples for OOD data, or fail to align their outlier expectations with reality.

Methods

AdaptOD tackles this problem through a two-pronged approach split between the training and inference phases:

  1. Dual-Normalized Energy Loss (DNE) [Training Phase]: Standard energy losses require manual tuning of sensitive margin hyperparameters and tend to suppress tail-class energy. DNE introduces Batch Energy Normalization, scaling logit outputs so that energy is balanced both class-wise (balancing total energy across classes) and sample-wise (balancing energy across individual samples). This effectively transfers energy knowledge from head to tail classes, creating a clean baseline outlier distribution without needing manually tuned margins.
  2. Dynamic Outlier Distribution Adaptation (DODA) [Inference/Test-Time Phase]: Instead of executing expensive online model retraining during deployment, DODA performs a lightweight Test-Time Adaptation (TTA). It uses an offline-calculated Z-score threshold to filter out likely OOD samples from the incoming test stream. It then applies a momentum update to dynamically shift the vanilla outlier distribution estimate ($P^{out}$) toward the true OOD distribution, calibrating the final OOD scores on the fly.
Figure 2: Overview of AdaptOD, which consists of two components, DODA (Left) and DNE (Right). Left: Each test sample is assigned a global energy-based OOD score G(x) to adapt the outlier distribution Pout. DODA then uses the adapted outlier distribution Pout to calibrate the global energy score G(x), obtaining the calibrated global energy score GP(x) as the OOD score. Right: For each iteration, DNE first applies Batch Energy Normalization on logit output to obtain the normalized energy, and then utilizes this energy to optimize a dual energy loss function at both the class and sample levels.

Datasets

The authors evaluated their approach on three popular long-tailed benchmarks:

  • In-Distribution (ID) Datasets: CIFAR10-LT, CIFAR100-LT, and the large-scale ImageNet-LT (tempered with an exponential decay imbalance ratio of $\rho = 100$).
  • Auxiliary Outliers (Proxy OOD): A 30k subset of TinyImages80M (for CIFAR) and ImageNet-Extra (for ImageNet-LT).
  • True OOD Evaluation Datasets: The SC-OOD benchmark (consisting of CIFAR, Texture, SVHN, LSUN, Places365, and TinyImageNet) and ImageNet-1k-OOD. Synthetic noise datasets (Gaussian, Rademacher, Blobs) were also tested.

Key Insights and Ideas

  • Proxy Outliers are Inherently Mismatched: The energy distribution of different OOD datasets varies wildly (as shown in Figure 1a). Assuming training outliers perfectly represent test-time OOD data leads to degraded performance.
  • Calibration Over Retraining: While existing test-time adaptation methods rely on backpropagation or massive feature memory banks, DODA proves that simply calibrating the expected outlier distribution is computationally lightweight and highly effective.
  • Dual Normalization Prevents Head-Class Bias: Balancing energy at both the class and sample level prevents head classes from drowning out tail classes, giving the test-time adaptation a much more accurate starting point.
Figure 1: (a) Mean energy distribution on six OOD datasets with CIFAR100-LT [3] as ID data. (b) The results of the energy distribution of the OOD dataset SVHN [31] using our proposed dynamic outlier distribution adaptation (DODA) and an existing energy loss EnergyOE [24], where the outlier data is taken from TinyImages80M [38]. (c) The results of using both of our proposed DODA and dual-normalized energy loss (DNE). (d) The ratio of the energy of each ID class to the aggregated energy of all ID classes.

Key Results

  • State-of-the-Art Performance: AdaptOD consistently outperforms competitive baselines (such as EnergyOE and COCL) across all benchmarks. For example, on CIFAR100-LT, AdaptOD significantly reduces the False Positive Rate (FPR@95) while maintaining high classification accuracy on long-tailed ID data.
  • Plug-and-Play Versatility: DODA can be integrated into existing OOD detectors as a plug-in component. When added to baselines like OE, EnergyOE, BERL, and COCL, it consistently boosts OOD detection metrics across the board.
  • Approaching the Oracle Upper Bound: Ablation studies show that AdaptOD's unsupervised test-time adaptation closely approximates an "Oracle model" that has perfect ground-truth knowledge of the test-time OOD data.

Limitations and Future Work

Despite its strong performance, AdaptOD still requires access to an auxiliary outlier dataset during the training phase, which might not always be available in specialized domains. Additionally, because DODA relies on a stream of test data to dynamically update its outlier distribution, its performance at the very beginning of a test stream could be less optimal before it has had time to adapt. The authors suggest that future work should explore optimizing the outlier distribution entirely during training to potentially eliminate the need for online test-time updates.

Summary updated

Abstract

One key challenge in Out-of-Distribution (OOD) detection is the absence of ground-truth OOD samples during training. One principled approach to address this issue is to use samples from external datasets as outliers (i.e., pseudo OOD samples) to train OOD detectors. However, we find empirically that the outlier samples often present a distribution shift compared to the true OOD samples, especially in Long-Tailed Recognition (LTR) scenarios, where ID classes are heavily imbalanced, \ie, the true OOD samples exhibit very different probability distribution to the head and tailed ID classes from the outliers. In this work, we propose a novel approach, namely normalized outlier distribution adaptation (AdaptOD), to tackle this distribution shift problem. One of its key components is dynamic outlier distribution adaptation that effectively adapts a vanilla outlier distribution based on the outlier samples to the true OOD distribution by utilizing the OOD knowledge in the predicted OOD samples during inference. Further, to obtain a more reliable set of predicted OOD samples on long-tailed ID data, a novel dual-normalized energy loss is introduced in AdaptOD, which leverages class- and sample-wise normalized energy to enforce a more balanced prediction energy on imbalanced ID samples. This helps avoid bias toward the head samples and learn a substantially better vanilla outlier distribution than existing energy losses during training. It also eliminates the need of manually tuning the sensitive margin hyperparameters in energy losses. Empirical results on three popular benchmarks for OOD detection in LTR show the superior performance of AdaptOD over state-of-the-art methods. Code is available at https://github.com/mala-lab/AdaptOD.
BibTeX
@inproceedings{miao2024long,
  author = {Wenjun Miao and Guansong Pang and Jin Zheng and Xiao Bai},
  title = {{Long-Tailed Out-of-Distribution Detection via Normalized Outlier Distribution Adaptation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=cesWi7mMLY},
}
Figure