Abstract
We present a simple and effective way to estimate the batch-norm statistics during test time, to fast adapt a source model to target test samples. Known as Test-Time Adaptation, most prior works studying this task follow two assumptions in their evaluation where (1) test samples come together as a large batch, and (2) all from a single test distribution. However, in practice, these two assumptions may not stand, the reasons for which we propose two new evaluation settings where batch sizes are arbitrary and multiple distributions are considered. Unlike the previous methods that require a large batch of single distribution during test time to calculate stable batch-norm statistics, our method avoid any dependency on large online batches and is able to estimate accurate batch-norm statistics with a single sample. The proposed method significantly outperforms the State-Of-The-Art in the newly proposed settings in Test-Time Adaptation Task, and also demonstrates improvements in various other settings such as Source-Free Unsupervised Domain Adaptation and Zero-Shot Classification.
Introduction
Deep learning models are notoriously brittle when faced with "domain shift"—changes in data distribution between training and deployment (e.g., a model trained on clear photos failing on grainy or foggy images). Test-Time Adaptation (TTA) aims to fix this by updating the model during inference without access to the original training data or ground-truth labels.
However, current state-of-the-art TTA methods (like TENT) rely on a major assumption: that test data arrives in large batches from a single, consistent distribution. In real-world applications—like a self-driving car processing a video feed or a mobile app analyzing a single user photo—data often arrives one-by-one (Batch Size = 1) and the environment can change rapidly. When the batch size is small, the statistics used for Batch Normalization become unstable, causing model performance to collapse.
Methods
The authors introduce the MixNorm Layer, a drop-in replacement for standard Batch Normalization (BN) layers. Its core innovation lies in how it estimates the mean ($\mu$) and variance ($\sigma$) used to normalize features by blending historical global statistics with local statistics derived from augmented views of the current input.
The layer maintains an exponential moving average of statistics from all previously seen test samples to provide a stable "anchor." To adapt to the specific shift of the current image, the model creates an augmented version of the input and calculates statistics across this tiny "mini-batch." The final statistics are a weighted combination: $$\mu_{mixed} = (1 - m)\mu_{global} + m\mu_{local}$$ where $m$ is a mixing scale. This allows the model to be responsive to the current image while remaining anchored by historical stability.
Evaluation and Key Results
The researchers evaluated MixNorm across challenging scenarios including CIFAR-10C and ImageNet-C, introducing two new evaluation protocols: varying batch sizes and mixed distributions (where every image in a batch might have a different corruption type).
Performance Highlights
- The "Batch of One" Success: On CIFAR-10C with a batch size of 1, the baseline TENT method has an error rate of 90.00% (total failure). MixNorm achieves 21.94%, nearly matching the performance of large-batch methods.
- ImageNet-C Performance: On ImageNet-C (Mixed Types), MixNorm maintains an error rate around 78.8% across all batch sizes, while TENT starts at 99.8% for small batches and only catches up when batches reach size 64.
- Source-Free UDA: In the SVHN to MNIST task, a variant called MixNormBN achieved an error rate of 7.95%, significantly outperforming TENT (8.17%) and standard BN (22.70%).
- Zero-Shot Boost: Applying MixNorm to a pre-trained CLIP model improved its zero-shot accuracy on CIFAR-100 from 40.97% to 45.13%.
Conclusion
MixNorm eliminates the traditional requirement for large, uniform batches during inference by using spatial augmentations as a statistical stabilizer. While the method introduces new hyperparameters like the mixing scale, it demonstrates remarkable stability in heterogeneous, real-world environments where previous state-of-the-art methods fail. Future work will explore dynamically adjusting the mixing scale based on the perceived uncertainty of incoming samples.
Summary updated