Benchmarking Test-Time Adaptation against Distribution Shifts in Image Classification

Yongcan Yu, Lijun Sheng, Ran He, Jian LiangarXiv 2023

Abstract

Test-time adaptation (TTA) is a technique aimed at enhancing the generalization performance of models by leveraging unlabeled samples solely during prediction. Given the need for robustness in neural network systems when faced with distribution shifts, numerous TTA methods have recently been proposed. However, evaluating these methods is often done under different settings, such as varying distribution shifts, backbones, and designing scenarios, leading to a lack of consistent and fair benchmarks to validate their effectiveness. To address this issue, we present a benchmark that systematically evaluates 13 prominent TTA methods and their variants on five widely used image classification datasets: CIFAR-10-C, CIFAR-100-C, ImageNet-C, DomainNet, and Office-Home. These methods encompass a wide range of adaptation scenarios (e.g. online adaptation v.s. offline adaptation, instance adaptation v.s. batch adaptation v.s. domain adaptation). Furthermore, we explore the compatibility of different TTA methods with diverse network backbones. To implement this benchmark, we have developed a unified framework in PyTorch, which allows for consistent evaluation and comparison of the TTA methods across the different datasets and network architectures. By establishing this benchmark, we aim to provide researchers and practitioners with a reliable means of assessing and comparing the effectiveness of TTA methods in improving model robustness and generalization performance.

Introduction

Deep neural networks are notoriously fragile when the data they encounter during deployment (test data) differs from the data they were trained on—a phenomenon known as distribution shift. While Test-Time Adaptation (TTA) has emerged as a promising way to update models on-the-fly using unlabeled test samples, the research landscape has remained fragmented. Existing methods are often evaluated under inconsistent settings, assuming different data arrival patterns or types of shifts (synthetic vs. natural). This study provides the first comprehensive "apples-to-apples" comparison to determine which TTA methods actually work and under what conditions.

Methodology and Paradigms

The benchmark categorizes TTA into three primary paradigms based on how data is received and processed during inference:

  1. Test-Time Batch Adaptation (TTBA): The model adapts to a single mini-batch of data.
  2. Online Test-Time Adaptation (OTTA): The model adapts incrementally as a sequence of batches arrives, potentially handling a shifting environment over time.
  3. Test-Time Domain Adaptation (TTDA): The model sees the entire unlabeled target domain and can perform multiple passes (epochs) over it.
Comparison of TTA paradigms: (a) TTBA, (b) OTTA, and (c) TTDA.

The researchers implemented 13 algorithms (including popular ones like Tent, CoTTA, and SHOT) within a unified PyTorch framework. They standardized variables like batch size and hyperparameter search strategies to ensure fairness. The benchmark utilizes five datasets covering different shifts: synthetic corruptions (CIFAR-10-C, CIFAR-100-C, ImageNet-C) and real-world natural shifts (Office-Home, DomainNet126).

Key Insights

  • The PredBN Paradox: PredBN (replacing training-time batch normalization statistics with test-time statistics) is highly effective for synthetic corruptions but often performs worse than the original model on natural-shift datasets. This suggests that natural shifts do not alter low-level feature statistics in the same way that noise or blur does.
  • Online vs. Offline Gap: By running online methods (OTTA) for multiple epochs, they can achieve results competitive with offline domain adaptation (TTDA) on corruption datasets. However, a discernible gap remains on natural-shift datasets, indicating that current online methods struggle to learn complex domain-level features.
  • Backbone Fragility: While Vision Transformers (ViTs) are generally more robust, they are more prone to "crashing" (diverging) during the adaptation process compared to ResNets, especially in weather-related tasks like snow or frost.
  • The Need for Sample Selection: Top-performing online methods like EATA and SAR use entropy-based sample selection—filtering out "unreliable" or "noisy" samples before updating the model. This highlights that in TTA, the quality of samples used for learning is just as important as the learning algorithm itself.

Experimental Results

The benchmark reveals that TTA significantly improves robustness against synthetic corruptions. On ImageNet-C, the best TTA methods improved accuracy from a baseline of 18.16% to over 50% (e.g., SAR-E10 reached 50.04%).

Accuracy of various TTA methods across different types of domain shifts on ImageNet-C.

Performance on natural shifts remains a challenge. On the Office-Home dataset, the source model started at 59.8%. While TTDA methods like NRC pushed this to 69.6%, many OTTA methods provided only marginal gains. However, using a ViT-B/16 backbone combined with TTA showed significant promise; the EATA-E10 method achieved a staggering 67.1% average accuracy on ImageNet-C, proving that modern architectures and TTA are a powerful combination for robustness.

Conclusion and Future Work

This work establishes a reliable means of assessing TTA methods, but several challenges remain. The benchmark is currently limited to image classification, and future work should expand to semantic segmentation and natural language processing. Furthermore, there is currently no "one-size-fits-all" algorithm that excels across all paradigms and shift types. Developing a universal TTA method that is robust across both synthetic and natural shifts remains an open and critical challenge for the community.

Summary updated

BibTeX
@misc{yu2023benchmarking,
  author = {Yongcan Yu and Lijun Sheng and Ran He and Jian Liang},
  title = {{Benchmarking Test-Time Adaptation against Distribution Shifts in Image Classification}},
  year = {2023},
  eprint = {2307.03133},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.03133},
}
Figure