Introduction
Deep learning models frequently encounter distribution shifts when deployed in real-world environments. Whether due to sensor noise, weather conditions, or hardware variations, these "covariate shifts" can significantly degrade performance. Test-Time Adaptation (TTA), and specifically Test-Time Batch Normalization (TTN), has emerged as a powerful remedy. TTN works by replacing a model's stored training statistics (mean and variance) in its BatchNorm layers with statistics calculated directly from the current batch of test data.
However, TTN possesses a critical vulnerability: it assumes that test batches are class-balanced. In many practical scenarios—such as a medical clinic experiencing a surge in a specific pathology—batches are heavily imbalanced, a phenomenon known as label shift. In these instances, standard TTN recalculates statistics that inadvertently "erase" the features necessary to distinguish between classes, leading to a total collapse in accuracy. This paper introduces Hybrid-TTN, a method designed to preserve the benefits of adaptation while maintaining stability against label shifts.
The Hybrid-TTN Framework
Hybrid-TTN moves away from the traditional "all-or-nothing" approach of adapting every channel in every BatchNorm layer. Instead, it selectively adapts channels based on their sensitivity to specific classes and their position within the network architecture. The method consists of three core components:
1. Channel-Level Scoring
Before deployment, the model undergoes a post-training analysis where training data is passed through the network class-by-class. The authors use the 2-Wasserstein distance to quantify how much each channel's activation statistics for a specific class deviate from the global training statistics. This process generates a "sensitivity map," identifying which channels are most biased toward specific labels and which remain relatively class-agnostic.
2. Depth-Wise Prior
Empirical observations reveal that network depth is a strong proxy for label sensitivity. Earlier layers in a neural network generally capture low-level features (like edges and textures) that are robust to label shift but sensitive to noise. Conversely, later layers are highly specialized for classification. Hybrid-TTN employs a linear decay strategy: it allows nearly all channels in the initial layers to adapt to noise while progressively freezing more channels in the deeper layers to maintain class stability.
3. Two-Pass Pseudo-Labeling
At inference time, the model performs a "warm-up" pass using a uniform class prior to generate initial predictions. These predictions are used to estimate the actual label distribution of the current batch. The model then executes a second, refined pass, adapting only the most appropriate channels based on the estimated distribution.
Experimental Evaluation
The researchers evaluated Hybrid-TTN across three diverse benchmarks:
- CIFAR-10-C and ImageNet-1K-C: Standard benchmarks for 15 types of image corruptions (e.g., blur, weather, and digital noise).
- Liver Ultrasound: A real-world medical dataset for fatty liver diagnosis. This dataset is particularly challenging because the source and target data originate from different hospitals using different equipment, and the class balance is naturally skewed.
Key Insights and Results
Hybrid-TTN consistently outperformed or matched state-of-the-art TTA methods like TENT, LAME, and DELTA, particularly in imbalanced scenarios.
- Robustness to Extreme Imbalance: In extreme cases where test batches contained only a single class, standard TTN accuracy on CIFAR-10 plummeted from ~95% to ~20%. Hybrid-TTN remained stable, maintaining approximately 87% accuracy.
- Superior Ranking: Across all tested scenarios involving varying corruption types and degrees of imbalance, Hybrid-TTN achieved the best median rank (1.0 on CIFAR-10, 2.3 on ImageNet, and 1.5 on Ultrasound).
- Clinical Utility: On the ultrasound dataset, Hybrid-TTN was the only method that consistently improved upon the source model's performance without succumbing to the biases that affected other methods.
- Efficiency: The method is computationally efficient, requiring only a simple post-training scoring step and two forward passes during inference, adding negligible overhead.
Limitations and Future Work
While effective, Hybrid-TTN has specific requirements. It is currently designed for architectures utilizing Batch Normalization, meaning it would require modification for Transformer-based models that use LayerNorm. Additionally, the "Post-Training" phase requires access to training data to calculate class-specific statistics, which may not be feasible in certain privacy-sensitive or black-box scenarios. Finally, the authors note that the linear decay for channel selection is a heuristic; future research could explore more dynamic ways to determine layer-wise adaptation based on the specific type of shift detected.
Summary updated