Abstract
Test-Time Adaptation (TTA) is a powerful paradigm for mitigating distribution shifts by adapting models to unlabeled data during deployment. However, standard TTA methods often fail in real-world scenarios where batch sizes are small, as they rely on noisy in-batch statistics. We introduce MemBN (Memory-based Batch Normalization), a method that stabilizes TTA by maintaining a statistics memory queue of previous test samples. MemBN effectively simulates large-batch stability, providing robust performance across diverse batch sizes and shifting domains. On CIFAR10-C with a batch size of 1, MemBN maintains a robust 12.88% error rate, whereas standard TTA methods collapse to a 90% error rate.
Introduction
Deep neural networks are highly sensitive to distribution shifts—differences between the data they were trained on (source domain) and the data they encounter during deployment (test domain). While Test-Time Adaptation (TTA) aims to fix this "on the fly," its heavy reliance on Batch Normalization (BN) statistics creates a significant bottleneck. In practical applications like edge computing or real-time streaming, batch sizes are often minimal (e.g., 1 or 2 samples). In these cases, "in-batch" statistics are noisy and unrepresentative, leading to a massive drop in accuracy or total model collapse. MemBN bridges the gap between academic benchmarks and practical, small-batch deployments by providing a stable statistical anchor.
The MemBN Framework
MemBN replaces standard BN layers with a memory-augmented version that aggregates information over time to ensure stability.
Statistics Memory Management
Instead of relying solely on the current noisy batch, each MemBN layer maintains a First-In-First-Out (FIFO) queue that stores the means and variances of the most recent test batches. The model calculates "average memory statistics" across this queue, effectively creating a "virtual batch size." This allows a model to act as if it is processing a batch of 128 or 200 samples even when it is only seeing a single sample at a time, providing a performance boost without increasing computational latency.
Domain Shift Detection and Adaptive Weighting
To handle continual TTA where environments change repeatedly, MemBN monitors the distance between new batch statistics and those in memory using a standard Z-score. If a new batch is statistically "too far" from the memory, the system assumes a new domain shift has occurred and resets the memory to prevent outdated data from polluting the adaptation.
Furthermore, MemBN uses a dynamic weighting factor ($\alpha$) to interpolate between original source statistics and new memory statistics. If a specific layer's data looks similar to the training data, the model leans on its original knowledge; if it looks very different, it prioritizes the memory statistics. To ensure stable gradients during optimization, the framework also integrates Batch Renormalization techniques to decouple normalization factors from the backpropagation path.
Experimental Evaluation
The researchers evaluated MemBN across several rigorous benchmarks, including CIFAR10-C, CIFAR100-C, and ImageNet-C, which involve 15 different corruption types. They also tested semantic segmentation tasks, pre-training on Cityscapes and testing on real-world datasets like BDD-100K and Mapillary. These tests covered single-domain shifts, continual shifts, and non-i.i.d. temporal streams.
Key Results
MemBN demonstrates superior stability and performance across all tested scenarios:
- Small Batch Superiority: On CIFAR10-C with a batch size of 1, standard TTA (TBN) collapses to a 90% error rate. MemBN maintains a robust 12.88% error rate.
- State-of-the-Art Performance: MemBN consistently outperformed existing SOTA methods like TENT, CoTTA, and TTN across batch sizes ranging from 200 down to 1.
- Large-Scale Scaling: On ImageNet-C, MemBN achieved an average error of 67.57%, significantly outperforming Group Normalization (69.38%), which is the traditional standard for small-batch robustness.
Conclusion
MemBN provides a simple yet effective solution for making Test-Time Adaptation work in the real world. By remembering the recent past, it provides the statistical stability necessary for accurate deployment on edge devices and real-time streams. While currently designed for BN-based architectures, future work may extend these memory-based concepts to other normalization layers like Layer Norm used in modern Vision Transformers.
Summary updated