Abstract
Domain shift is a common problem in the realistic world, where training data and test data follow different data distributions. To deal with this problem, fully test-time adaptation (TTA) leverages the unlabeled data encountered during test time to adapt the model. In particular, Entropy-Based TTA (EBTTA) methods, which minimize the prediction's entropy on test samples, have shown great success. In this paper, we introduce a new perspective on the EBTTA, which interprets these methods from a view of clustering. It is an iterative algorithm: 1) in the assignment step, the forward process of the EBTTA models is the assignment of labels for these test samples, and 2) in the updating step, the backward process is the update of the model via the assigned samples. Based on the interpretation, we can gain a deeper understanding of EBTTA, where we show that the entropy loss would further increase the largest probability. Accordingly, we offer an alternative explanation that why existing EBTTA methods are sensitive to initial assignments, outliers, and batch size. This observation can guide us to put forward the improvement of EBTTA. We propose robust label assignment, weight adjustment, and gradient accumulation to alleviate the above problems. Experimental results demonstrate that our method can achieve consistent improvements on various datasets.
Introduction: The Challenge of Domain Shift
Deep learning models often struggle when encountering "domain shift"—discrepancies between training data and real-world deployment conditions, such as a model trained on clear-day images attempting to process foggy or noisy scenes. Test-Time Adaptation (TTA) addresses this by allowing models to adapt to new conditions using only the unlabeled data encountered during inference.
A popular approach, TENT, minimizes the entropy of model predictions to increase certainty. However, TENT is notoriously sensitive to batch sizes; in low-batch scenarios (e.g., batch size = 1), performance often collapses, sometimes falling below the original unadapted model. This research seeks to understand the mechanics of this failure and proposes a more reliable framework.
The Clustering Perspective
This paper reinterprets entropy-based TTA through the lens of unsupervised clustering. The authors demonstrate that the adaptation process functions as an iterative algorithm:
- The Assignment Step (Forward Pass): The model assigns labels to test samples based on current weights.
- The Updating Step (Backward Pass): The model updates its weights (effectively moving "cluster centers") based on these assignments.
Mathematical analysis (Lemma 1) reveals that minimizing entropy implicitly increases the probability of the most likely class, driving the model toward "one-hot" overconfidence. As shown in the figure below, this process forces the model to converge on a single class assignment over iterations.
This view explains why small batches fail: a batch size of 1 forces the "cluster center" to update based on a single, potentially noisy point without the stabilizing effect of averaging, leading to rapid model drift.
Test-Time Clustering (TTC)
To address these vulnerabilities, the authors propose Test-Time Clustering (TTC), incorporating several robust components:
- Robust Label Assignment (RLA): The model averages predictions from the original image and a weakly augmented version (e.g., horizontal flip) to create a stable pseudo-label.
- Similarity-Preserving Constraint (SPC): This forces the model to maintain similar predictions for similar inputs, ensuring feature-space coherence.
- Sample Selection (SS): The framework dynamically filters out "outliers"—samples with high entropy—to prevent unreliable data from corrupting the update.
- Gradient Accumulation (GA): By accumulating gradients over multiple steps, TTC simulates larger batch sizes, providing stability even in stream-based applications with small real-time batches.
Key Results
TTC was evaluated on standard benchmarks including CIFAR-10-C, CIFAR-100-C, and ImageNet-C. It consistently outperformed TENT and other state-of-the-art methods. On CIFAR-10-C, TTC achieved an average accuracy of 82.5%, significantly higher than the source model's 56.5% and TENT's 81.5%.
Notably, TTC maintains high performance in small-batch scenarios where TENT typically fails. For instance, while TENT's accuracy on CIFAR-10-C drops sharply at a batch size of 1, TTC’s use of gradient accumulation ensures robustness, making it suitable for practical, real-time deployment.
Conclusion
By framing entropy minimization as implicit clustering, this work provides a theoretical foundation for the instabilities observed in existing TTA methods. The resulting TTC framework offers a more robust, stable, and accurate solution for adapting models to new domains on the fly, particularly in challenging, low-data-density environments.
Summary updated