Learning Label Shift Correction for Test-Agnostic Long-Tailed Recognition

Tong Wei, Zhen Mao, Zi-Hao Zhou, Yuanyu Wan, Min-Ling Zhang

TL;DR

Label Shift Correction (LSC) is a novel "plug-and-play" method that enables long-tailed recognition models to adapt to unknown test distributions. By using a shallow neural network to estimate the test label distribution and applying an adaptive logit-clipping technique, LSC significantly reduces generalization error across diverse real-world scenarios without requiring prior knowledge of the test set.

The Challenge of Agnostic Test Distributions

In the real world, data is rarely balanced. "Long-tailed" datasets—where a few "head" classes have many samples while most "tail" classes have very few—are the norm. Most research in long-tail learning (LTL) assumes that while the training data is skewed, the test data will be perfectly balanced (uniform).

However, in applications like autonomous driving or recommendation systems, the test distribution is often agnostic (unknown). A model might encounter a test set that is also long-tailed, or even "inversely" long-tailed (where rare classes suddenly become common). Existing LTL methods often fail in these "test-agnostic" settings because they are hard-coded to expect a uniform distribution. The core challenge is enabling a model to accurately estimate the label distribution of an unlabeled test set and adjust its predictions on the fly.

Introducing Label Shift Correction (LSC)

To address this, the authors introduce Label Shift Correction (LSC), which operates in three main stages:

  1. Generalized Black Box Shift Estimation (GBBSE): Instead of relying on traditional statistical methods that struggle with rare classes, LSC trains a "neural estimator"—a shallow multi-layer perceptron (MLP). This estimator is trained by simulating thousands of different label distributions using the training data. It learns to map the average "logits" (raw model outputs) of a data subset to its underlying class distribution.
  2. Logit Clipping (LogitClip): Long-tail models often produce "inflated" or overconfident scores for tail classes to compensate for their rarity. This noise can confuse the distribution estimator. LSC introduces LogitClip, which zeros out small, noisy logits to provide a cleaner signal.
  3. Adaptive Adjustment: At test time, the neural estimator predicts the test distribution. The model then uses an adaptive clipping strategy to choose the best threshold $k$ based on whether the test set appears head-heavy or tail-heavy. Finally, it adjusts the original model's predictions using the estimated distribution.
Effect of the LogitClip threshold $k$ on accuracy across various test distributions. Adaptive adjustment selects the optimal $k$ based on the estimated distribution.

Key Insights and Theoretical Foundation

  • Theory-Driven Correction: The authors provide a theoretical proof showing that the gap between a model's error and the optimal (Bayes) error is directly bounded by how well the test label distribution can be estimated.
  • The "Tail Bias" Trap: They discovered that long-tail models are often too good at boosting tail classes, leading to inflated logits that ruin distribution estimation. Logit clipping acts as the crucial fix that strips away this overconfidence to reveal the true underlying distribution.
  • Unnormalized Logits: Interestingly, training the neural estimator on raw, unnormalized logits works better than using normalized probabilities, as raw logits preserve more information about the model's uncertainty across different classes.
Estimated label distribution before and after adjustment, demonstrating LSC's ability to closely match the true prior distribution.

Datasets and Key Results

The authors evaluated LSC on three standard long-tail benchmarks (CIFAR100-LT, ImageNet-LT, and Places-LT), simulating various test-time shifts such as Forward (matching training), Uniform, and Backward (inversely long-tailed).

LSC consistently outperformed state-of-the-art (SOTA) methods like SADE and LADE across all datasets and test distributions:

  • ImageNet-LT Performance: LSC achieved 72.3% accuracy on "forward" shifts and 57.3% on "backward" shifts, outperforming the previous best (SADE) by 2.9% and 4.2% respectively.
  • Versatility: LSC acts as a "wrapper" method. When combined with other SOTA models like NCL or SHIKE, it consistently boosted their performance, sometimes by as much as 6.5% in challenging backward-shift scenarios.
  • Robustness: The method remains stable even when the test set is more imbalanced than anything seen during the neural estimator's training.

Limitations and Future Work

  • Base Model Dependency: Because LSC is a post-processing step, if the underlying pre-trained model is extremely poor at representing certain classes, the signal in the logits might be too weak for the neural estimator to recover an accurate distribution.
  • Offline Simulation: Training the neural estimator requires simulating many subsets of data. While efficient (taking only a few minutes), it adds an extra step to the pipeline.
  • Future Directions: The authors suggest exploring how these techniques could apply to other types of "agnostic" shifts, such as changes in image style or background (domain shift), rather than just label frequency.

Summary updated

BibTeX
@inproceedings{wei2024learning,
  author = {Tong Wei and Zhen Mao and Zi-Hao Zhou and Yuanyu Wan and Min-Ling Zhang},
  title = {{Learning Label Shift Correction for Test-Agnostic Long-Tailed Recognition}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=J3xYTh6xtL},
}
Figure