Progressive Conditioned Scale-Shift Recalibration of Self-Attention for Online Test-time Adaptation

Yushun Tang, Ziqiong Liu, Jiyuan Jia, Yi Zhang, Zhihai HearXiv 2025 · DOI

Abstract

Online Test-Time Adaptation (TTA) is critical for maintaining the performance of machine learning models when they encounter out-of-distribution data in real-world scenarios. While effective for convolutional architectures, existing TTA methods often struggle with Vision Transformers (ViTs) due to the sensitivity of the self-attention mechanism to domain shifts. This paper introduces Progressive Conditioned Scale-Shift Recalibration (PCSR), a novel framework that adaptively recalibrates the internal features of ViTs. By extracting layer-wise domain tokens and generating scale-shift factors, PCSR effectively aligns the model's attention mechanism to the target domain on the fly, achieving state-of-the-art results across multiple robustness benchmarks.

Introduction

Machine learning models frequently encounter "domain shift," a phenomenon where the distribution of test data (e.g., images corrupted by noise, weather, or blur) differs from the training data. Online Test-Time Adaptation (TTA) seeks to mitigate this performance drop by updating the model parameters during inference using only the unlabeled test samples.

Vision Transformers (ViTs) have become a dominant architecture in computer vision, yet they present unique challenges for TTA. Research indicates that domain shifts cause significant drift in the Query (Q), Key (K), and Value (V) features within self-attention modules. Because these features dictate how the model relates different parts of an image, even minor shifts can lead to catastrophic failures in reasoning and classification accuracy.

Methodology: The PCSR Framework

The proposed Progressive Conditioned Scale-Shift Recalibration (PCSR) framework introduces a lightweight, adaptive mechanism to correct feature drift at every layer of the Transformer.

Figure 6: t-SNE visualizations of learned Domain tokens across different corruption types. The clustering demonstrates that the DSN successfully isolates domain-specific information from semantic content.

PCSR consists of three primary components updated during inference:

  1. Domain Separation Network (DSN): At each layer, the DSN processes image patch tokens to distill a single Domain token ($D^l$). This token serves as a representative signature of the specific noise or corruption present in the input. To ensure the token accurately captures the domain essence, the authors employ a Similarity Loss based on the Fermat-Weber point location problem, forcing the domain token to be the geometric median of all patch features in that layer.
  2. Factor Generator Network (FGN): The FGN utilizes the Domain token and the existing Class token to predict two recalibration factors: scale ($\gamma$) and shift ($\beta$).
  3. Scale-Shift Recalibration: These factors are applied directly to the Q, K, and V features ($Q' = \gamma Q + \beta$, etc.) before the attention score is computed. This process "re-centers" the attention mechanism, allowing it to process corrupted data as if it were clean source-domain data.

The adaptation is guided by a Reliable Entropy Loss, which encourages confident predictions on the target data without requiring ground-truth labels.

Experimental Evaluation

The authors evaluated PCSR against several competitive benchmarks designed to test model robustness:

  • ImageNet-C: 15 types of image corruptions (e.g., frost, fog, digital noise) at varying severities.
  • ImageNet-R & ImageNet-A: Datasets containing artistic renditions and naturally occurring adversarial examples.
  • VisDA-2021: A large-scale cross-domain adaptation dataset.

Key Results

PCSR consistently outperformed state-of-the-art TTA methods such as TENT and SAR:

  • ImageNet-C (Severity 5): Achieved 67.5% average accuracy, a 3.9% improvement over previous benchmarks.
  • ImageNet-A: Reached 52.1% accuracy, representing a significant jump from the 45.3% achieved by the runner-up.
  • Efficiency: The authors found that sharing the same scale and shift factors across Q, K, and V components maintained performance while reducing parameter overhead and increasing training speed by approximately 17%.

Discussion and Insights

A critical finding of this research is that domain shift is both local and global. By extracting domain tokens at every layer, PCSR progressively "peels away" the shift as data flows through the network.

Figure 6: t-SNE visualizations of learned Domain tokens across different corruption types. The clustering demonstrates that the DSN successfully isolates domain-specific information from semantic content.

Visualization via t-SNE (as seen in Figure 6) confirms that the learned Domain tokens naturally cluster by corruption type (e.g., all "snow" or "pixelate" images cluster together) regardless of the object class. This provides empirical evidence that the DSN successfully isolates domain-specific noise from the semantic content of the image.

Conclusion

PCSR provides a robust and efficient solution for adapting Vision Transformers to challenging real-world environments. By focusing on the recalibration of the self-attention mechanism through layer-wise domain tokens, the method achieves superior accuracy on corrupted and out-of-distribution data. Future work will explore extending this conditioned recalibration technique to more complex tasks such as object detection and semantic segmentation, as well as investigating its applicability to CNN-based architectures.

Summary updated

BibTeX
@misc{tang2025progressive,
  author = {Yushun Tang and Ziqiong Liu and Jiyuan Jia and Yi Zhang and Zhihai He},
  title = {{Progressive Conditioned Scale-Shift Recalibration of Self-Attention for Online Test-time Adaptation}},
  year = {2025},
  eprint = {2512.12673},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.12673},
}
Figure