NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TTN: A Domain-Shift Aware Batch Normalization in Test-Time Adaptation

Hyesu Lim, Byeonggeun Kim, Jaegul Choo, Sungha Choi

When deploying deep learning models in the real world, they frequently encounter "domain shifts"—changes in lighting, weather, or camera sensors that differ from the training data. To handle this, researchers use Test-Time Adaptation (TTA) to tweak models on the fly. However, most TTA methods suffer from a "small batch" problem: they perform well with large batches of images but degrade severely when processing images individually or in very small groups.

In their ICLR 2023 paper, Hyesu Lim and colleagues introduce TTN (Test-Time Normalization), a domain-shift-aware strategy that ensures models remain robust even when the test batch size is tiny.

The Achilles' Heel of Test-Time Adaptation

The core vulnerability in modern Test-Time Adaptation lies in Batch Normalization (BN).

Standard BN uses "Conventional BN" (CBN), which relies on fixed statistics (mean and variance) learned during training. When the domain shifts, these source statistics become invalid, leading to misclassification. To counter this, many TTA methods employ "Transductive BN" (TBN), which recalculates statistics directly from the incoming test batch.

Visualizing domain shift and the small batch problem

The catch? TBN assumes the test batch is large and representative. If the batch size is small (e.g., 1 or 2 images), the calculated statistics become incredibly noisy. If the data distribution changes continuously, the model cannot keep up. This leads to a massive performance drop—sometimes spiking error rates from 15% to 90% simply by reducing the batch size.

Test-Time Normalization (TTN)

To resolve this, the authors propose Test-Time Normalization (TTN), which acts as a bridge between the stability of CBN and the adaptability of TBN.

Comparison of BN layers and the TTN pipeline

1. The TTN Layer

TTN introduces a learnable, channel-wise interpolating weight, $\alpha$. It calculates the final normalization statistics as a weighted average of source and test statistics:

  • If $\alpha$ is near 1, the model trusts the test batch (acting like TBN).
  • If $\alpha$ is near 0, the model trusts the source data (acting like CBN).

2. The Post-Training Phase

Before deployment, TTN undergoes a "post-training" phase using the original source data to determine how much to trust each layer:

  • Obtaining the Prior: The authors simulate domain shifts using data augmentation. They compare the gradients of "clean" images versus "augmented" images. If a specific channel's gradient changes significantly under augmentation, it is flagged as "domain-shift sensitive."
  • Optimizing $\alpha$: They fine-tune the $\alpha$ values for every channel in every BN layer. The goal is to find the optimal balance: adapting where necessary while preserving well-trained source knowledge where the shift doesn't matter. Interestingly, they found that shallow layers (closer to the input) are generally more sensitive to domain shifts (like style or texture), while deeper layers are more stable (capturing content). TTN automatically learns to weight TBN higher in shallow layers and CBN higher in deeper ones.

Key Results and Performance

The researchers evaluated TTN across rigorous benchmarks, including ImageNet-C, CIFAR-10/100-C, and various semantic segmentation datasets for autonomous driving (e.g., Cityscapes to BDD-100K).

  • Small Batch Robustness: On CIFAR-10-C, while TBN-based methods saw error rates explode to 90% at a batch size of 1, TTN maintained a stable error rate of ~18%.
  • Plug-and-Play Compatibility: TTN is a drop-in layer that can be combined with other popular TTA methods like TENT or SWR. In "continual" adaptation scenarios, TTN combined with SWR achieved an average error of 24.49% on CIFAR-10-C, outperforming the baseline SWR (30.75%).
  • Large-Scale Success: On ImageNet-C, TTN reduced the average error of a ResNet-50 from 86.40% (TBN) to 78.48%.
  • Segmentation Gains: In domain generalization for driving scenes, TTN improved the mean Intersection over Union (mIoU) on the BDD-100K dataset from 43.12% to 47.40% compared to standard TBN.

Limitations and Future Work

While highly effective, TTN requires access to the source training data and labels during the "post-training" phase to calculate the sensitivity prior. This may not be feasible in strict "source-free" scenarios where only the pre-trained model is provided. Additionally, $\alpha$ is optimized once before deployment and remains fixed at test-time. A promising future direction is developing a mechanism to dynamically adjust $\alpha$ during inference based on the specific severity and characteristics of the incoming test stream.

Summary updated

BibTeX
@inproceedings{lim2023ttn,
  author = {Hyesu Lim and Byeonggeun Kim and Jaegul Choo and Sungha Choi},
  title = {{TTN: A Domain-Shift Aware Batch Normalization in Test-Time Adaptation}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=EQfeudmWLQ},
}
Figure