Introduction
Deep learning models often struggle with "domain shift," where deployment data (the target domain) differs significantly from the training data (the source domain). Test-Time Adaptation (TTA) addresses this by updating models on-the-fly using the incoming stream of unlabeled test data. While effective with large batches, standard TTA methods often fail in realistic, small-batch scenarios—such as processing one or two samples at a time.
The Diversity Gap
The core contribution of this work is identifying the "Diversity Gap." While previous research attributed TTA failure in small batches to insufficient sample size, this paper demonstrates that the primary culprit is a lack of class diversity. As batch size decreases, the expected number of unique classes represented in a single batch drops significantly. This leads to "inexact" Batch Normalization (BN) statistics that derail the normalization process and destabilize the model.
Proposed Method: TEMA and Layer-wise Rectification
To overcome the diversity gap without requiring expensive training, backpropagation, or complex hyperparameter tuning, the authors propose a training-free approach consisting of three main components:
- Test-time Exponential Moving Average (TEMA): Instead of calculating BN statistics solely from the current tiny batch, TEMA maintains a running average of statistics from previous batches. This effectively expands the "sample pool," incorporating a more diverse set of class information over time.
- Adaptive Momentum: The momentum of the EMA is dynamically adjusted to balance the need for global class diversity with the need to stay relevant to the local context of the current batch.
- Layer-wise Rectification Strategy: The model blends source (training) and target (test) statistics based on inter-domain divergence (calculated via KL divergence). If a layer's statistics deviate wildly from the source, the model relies more on stable source statistics to prevent "model collapse."
Evaluation and Results
The method was evaluated on standard robustness benchmarks (CIFAR-10-C, CIFAR-100-C, and ImageNet-C) across various shift patterns, including "Gradual" shifts where corruption severity changes incrementally over time.
Key Findings:
- Consistency across Batch Sizes: On CIFAR-10-C, the proposed method's error rate only increased from 20.20% (batch size 200) to 21.05% (batch size 1). In contrast, the popular TENT method saw error rates skyrocket to 90% as batch sizes shrank.
- Superior Stability: By stabilizing BN statistics through diversity-aware moving averages, the model avoids the catastrophic forgetting and instability common in optimization-based TTA methods.
Conclusion
By unraveling the role of class diversity in Batch Normalization, this work provides a simple yet powerful solution for robust Test-Time Adaptation. The training-free nature of TEMA makes it highly practical for real-world deployment where computational resources and batch sizes are frequently limited.
Summary updated