Label Shift Adapter for Test-Time Adaptation under Covariate and Label Shifts

Sunghyun Park, Seunghan Yang, Jaegul Choo, Sungrack Yun

TL;DR

Existing test-time adaptation (TTA) methods break down when a model faces both domain changes (covariate shift) and class imbalance changes (label shift) simultaneously. This paper introduces a lightweight Label Shift Adapter that dynamically adjusts a pre-trained model's parameters based on an online estimate of the target domain's label distribution. By updating only a fraction of the network, it achieves state-of-the-art robustness against severe distribution shifts with negligible computational overhead.

What Problem Does This Paper Address?

Deep neural networks frequently struggle when deployed in new environments due to distribution shifts. Test-Time Adaptation (TTA) has emerged as a popular solution, allowing models to adapt on-the-fly to unlabeled test data during inference.

However, standard TTA methods operate under a massive assumption: that the data is class-balanced. In the real world, data is naturally long-tailed (e.g., a few common classes dominate), and class proportions shift drastically between domains (e.g., far more bicycle images in a city vs. a forest).

When covariate shift (changes in data appearance) and label shift (changes in class proportions) coexist, traditional TTA techniques like entropy minimization fail catastrophically. Because the source model is inherently biased toward the majority classes it was trained on, blindly maximizing prediction confidence causes the model to double down on its biases, completely ignoring minority classes.

Figure 2. Plots of accuracy with different degrees of label shift in CIFAR-10-C [14]. Although we train source model using balanced softmax [39], most TTA baselines show lower performance than source model, when label shift is severe. On the other hand, our method is more robust to label shifts than other TTA methods.

Methods

The authors propose a two-stage strategy featuring a novel Label Shift Adapter ($G_\phi$), which acts as a miniature hypernetwork to modulate the main model.

  1. Before Deployment (Training the Adapter): The main source model is frozen. The Label Shift Adapter is trained on the source dataset by simulating a wide variety of label distributions (e.g., uniform, forward long-tailed, and completely inverted/backward long-tailed). It learns to map a given label distribution to the optimal parameter adjustments needed to counteract class bias. This is optimized using a generalized logit adjusted loss, where a hyperparameter $\tau$ dynamically shifts the decision boundary depending on the simulated imbalance.
Figure 3. Overview of the proposed method. (a) We take a frozen pre-trained source model trained with Ds. (b) Before model deployment, we train a label shift adapter with a frozen source pre-trained model. (c) After model deployment, we adapt the model to the target domain by integrating the label shift adapter into other TTA algorithms.
  1. After Deployment (Online Test-Time Adaptation): During inference, the model encounters unlabeled target data batch-by-batch. The system estimates the true target label distribution online using an exponential moving average (EMA) of the model's predictions. This estimated distribution is fed into the Label Shift Adapter, which instantly outputs weight and bias corrections ($\Delta W, \Delta b$) for the classifier layer, alongside affine scaling parameters ($\gamma_h, \beta_h$) for the final feature map. Concurrently, standard TTA updates (like adjusting batch normalization parameters) are used to handle the covariate shift.
Figure 4. Visualization for understanding τ in a generalized logit adjusted loss. By adjusting τ, we can control the bias during train- ing. As τ increases, the decision boundary

Datasets

The method was validated across six distinct, heavily imbalanced setups:

  • Imbalanced Corruption Benchmarks: Long-tailed variants of CIFAR-10-C, CIFAR-100-C, and ImageNet-C featuring 15 different environmental corruptions evaluated across multiple target distributions (Forward, Uniform, and Backward).
  • Domain Adaptation Benchmarks: VisDA-C (RSUT) and OfficeHome (RSUT), modified to follow reverse Pareto distributions to simulate severe label shifts.
  • DomainNet: A massive multi-domain dataset (Real, Clipart, Painting, Sketch) utilized to evaluate performance under naturally occurring label shifts.

Key Insights and Ideas

  • Entropy Minimization is a Double-Edged Sword: Making predictions more confident works well when a domain simply looks different. However, if the model is already biased due to long-tailed training data, entropy minimization acts as a positive feedback loop for its mistakes.
  • Targeted Parameter Modulation: Instead of trying to generate weights for an entire deep network, the adapter only predicts adjustments for the final classification layer and its immediate inputs. This targeted approach makes the hypernetwork incredibly easy to train and completely architecture-agnostic.
  • Simulation Breeds Generalization: By forcing the adapter to learn how to fix the model under completely inverted class distributions during the pre-deployment phase, it becomes highly capable of handling entirely unknown target distributions at test time.

Key Results

  • Overcoming Severe Shift: On CIFAR-100-C under severe backward label shift (where the rarest training classes suddenly become the most common test classes), the proposed method combined with IABN achieved 25.50% accuracy, vastly outperforming standard TENT (11.25%) and the unadapted source model (11.12%).
  • ImageNet Scale Success: On ImageNet-C, integrating the adapter yielded an average absolute accuracy gain of +3.87% when paired with TENT and +3.08% when paired with IABN.
  • Negligible Overhead: For a ResNet-18 backbone, the adapter adds a mere 0.11M MACs and 0.12M parameters, ensuring it can easily run in real-time edge computing scenarios.

Limitations and Future Work

  • Extra Pre-Deployment Phase: The primary limitation is that the method requires an additional training stage to optimize the adapter before the model can be deployed to production.
  • Normalization Dependencies: While the adapter successfully mitigates label shift at the classifier level, the system still relies heavily on robust underlying normalization layers (like Instance-Aware Batch Normalization) to stabilize batch statistics. The authors note that improving the inherent robustness of normalization layers to extreme label shifts remains an open and vital direction for future TTA research.

Summary updated

BibTeX
@misc{park2023label,
  author = {Sunghyun Park and Seunghan Yang and Jaegul Choo and Sungrack Yun},
  title = {{Label Shift Adapter for Test-Time Adaptation under Covariate and Label Shifts}},
  year = {2023},
  eprint = {2308.08810},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.08810},
}
Figure