Abstract
Test time adaptation is the process of adapting, in an unsupervised manner, a pre-trained source model to each incoming batch of the test data (i.e., without requiring a substantial portion of the test data to be available, as in traditional domain adaptation) and without access to the source data. Since it works with each batch of test data, it is well-suited for dynamic environments where decisions need to be made as the data is streaming in. Current test time adaptation methods are primarily focused on a single source model. We propose the first completely unsupervised Multi-source Test Time Adaptation (MeTA) framework that handles multiple source models and optimally combines them to adapt to the test data. MeTA has two distinguishing features. First, it efficiently obtains the optimal combination weights to combine the source models to adapt to the test data distribution. Second, it identifies which of the source model parameters to update so that only the model which is most correlated to the target data is adapted, leaving the less correlated ones untouched; this mitigates the issue of "forgetting" the source model parameters by focusing only on the source model that exhibits the strongest correlation with the test batch distribution. Experiments on diverse datasets demonstrate that the combination of multiple source models does at least as well as the best source (with hindsight knowledge), and performance does not degrade as the test data distribution changes over time (robust to forgetting).
Introduction
In the real world, data is rarely static. An autonomous vehicle might start its journey under a clear blue sky, only to encounter fog, then rain, and eventually snow. For deep learning models, these "distribution shifts" are notorious performance killers. While techniques exist to adapt models to new environments, doing so continually, on-the-fly, and without original training data remains a significant hurdle.
MeTA (Multi-source Test Time Adaptation), also referred to as CONTRAST (CONtinual mulTi-souRce Adaptation to dynamic diStribuTions), is a framework designed to intelligently manage an ensemble of source models to navigate these shifting distributions. Presented at NeurIPS 2024, MeTA optimally blends multiple pre-trained models to handle evolving data distributions while neutralizing the "catastrophic forgetting" that plagues traditional adaptation methods.
The Challenge of Dynamic Environments
Most machine learning models are "brittle"—they perform well on data that looks like their training set but fail when the environment changes. Unsupervised Domain Adaptation (UDA) helps, but it usually requires access to the original source data, which is often restricted due to privacy or storage concerns.
Test-Time Adaptation (TTA) is a more modern approach that adapts models using only the incoming stream of unlabeled test data. However, existing TTA methods face two major issues:
- Single-Source Limitation: They typically adapt only one pre-trained model, missing out on the collective expertise of a diverse model ensemble.
- Catastrophic Forgetting: As a model adapts to a new condition (e.g., "Rain"), it often forgets how to handle previous ones (e.g., "Sun"). In a dynamic environment where conditions fluctuate, this leads to a steady decline in overall reliability.
As shown in Figure 1, the goal is to take a set of specialized models (Sun, Rain, Snow) and determine how to combine and update them as the weather changes in real-time.
The MeTA Framework
The MeTA framework operates in two main steps for every incoming batch of test data:
1. Optimal Model Blending
Instead of picking just one "best" model, MeTA learns a set of combination weights ($w$) to create a weighted ensemble. It finds these weights by minimizing the Shannon entropy of the ensemble's predictions. High entropy indicates model confusion, while low entropy signifies confidence. To ensure real-time performance, MeTA employs smart initialization using Batch Normalization statistics and an approximate Newton’s method for fast convergence.
2. Selective Model Update
This is the core mechanism for preventing forgetting. Instead of updating all models in the ensemble, MeTA identifies the single most relevant model (the one with the highest weight) and updates only its parameters.
As illustrated in Figure 2, by leaving the other models "frozen," MeTA preserves their original expertise. If conditions return to a previous state, the corresponding model remains pristine and ready for use.
Key Results and Insights
The researchers evaluated MeTA across a wide variety of tasks, including digit recognition, object recognition (Office-Home), robustness benchmarks (CIFAR-10/100C), and semantic segmentation (Cityscapes to ACDC). Key findings include:
- Superior Accuracy: On CIFAR-100C, MeTA achieved an average error rate of 34.2%, significantly lower than the best single-source adaptation (39.9%) and far better than a standard source model (54.5%).
- Zero Forgetting: In long-term experiments with 15 sequential distribution shifts, MeTA maintained near-perfect accuracy on the original source domains, while baselines like Tent saw their source accuracy plummet.
- Efficiency: By using second-order optimization, weight learning is performed extremely quickly, making it viable for streaming applications.
Conclusion
MeTA demonstrates that a weighted combination of models almost always outperforms the single best source model, especially when the test distribution is a mix of multiple domains. By selectively updating only the most correlated model, the framework minimizes excess risk while preventing parameter drift. Future work will explore "sub-batch" adaptation to handle scenarios where a single batch contains a mix of different domains.
Summary updated