Manuscript Offprint
arXiv:2611.26234Attention Drift Regularization with Adaptive Initialization for Domain-Robust Visual Recognition
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Source-free domain adaptation (SFDA) adapts a pre-trained source model to unlabeled target domains without source data access, yet two critical failure modes remain unaddressed. First, attention drift: source-learned attention maps shift toward spurious or background features under distribution shift, destabilizing feature representations. Second, domain-gap-agnostic initialization: applying a single fixed source model uniformly across all target domains ignores domain gap severity, causing premature overfitting to noisy pseudo-labels under large shifts. We propose DGA-CAFC to address both failures. The Counterfactual Attention-based Feature Consistency (CAFC) module enforces feature stability by minimizing the discrepancy between representations computed under learned attention and those under counterfactual-inspired normalized perturbations, thereby promoting domain-robust features independent of spurious attention shifts. The Domain-Gap Aware Source Model Selection (DGASS) module estimates domain gap severity via target prediction entropy and selects the source model variant whose confidence level best matches the estimated gap, reducing negative transfer and stabilizing pseudo-label quality. Crucially, CAFC transfers beyond SFDA: applied as a lightweight regularizer to standard domain generalization objectives without target data. Extensive experiments across SFDA and DG benchmarks demonstrate that our method consistently improves over recent baselines, demonstrating the effectiveness and generality of the proposed framework. Project page is available at https://visdomlab.github.io/DGA_CAFC
1 Introduction
Visual recognition models trained on a labelled source domain degrade when deployed under distribution shift caused by differences in imaging conditions, object appearance, texture, background composition, or acquisition device. Two settings address this without full re-annotation of the target domain. In source-free domain adaptation (SFDA) [14, 30, 29, 12], a source-trained model and unlabeled target data are available at adaptation time, but the source training set is inaccessible due to privacy or storage constraints. In domain generalization (DG) [4, 19], no target data are available during training at all; the model must generalize to unseen domains at test time. Both settings demand representations that are stable under covariate shift, yet the mechanisms by which standard training produces fragile representations remain insufficiently characterized.
Transformer-based backbones [3, 16] dominate visual recognition, including domain adaptive models [27, 21]. Their self-attention mechanism aggregates features from all spatial tokens, weighting each by a learned attention map derived from source-domain statistics. Under target-domain shift, these attention maps can drift toward spurious or background features that are discriminative in the source domain but not in the target, a phenomenon we term attention drift. Attention drift destabilizes the attention-conditioned feature representations on which downstream tasks depends: in SFDA, where a teacher model generates pseudo-labels from these representations, corrupted features propagate errors into the pseudo-label signal and compound through self-training; in DG, drifted attention patterns reduce robustness to the appearance variations encountered at test time on unseen domains. Despite the broad adoption of attention-based backbones, existing SFDA and DG methods do not directly target the stability of attention-conditioned features under distribution shift. A second, SFDA-specific failure mode arises at initialisation. Standard SFDA methods [14, 27] initialise the student model from a single fixed source checkpoint regardless of the severity of the domain gap between source and target. This is suboptimal because gap severity varies substantially across transfer tasks: a high-gap pair requires a conservative initialisation that does not over-commit to source-domain decision boundaries, whereas a low-gap pair benefits from a confident initialisation that accelerates pseudo-label convergence. Ignoring this distinction causes premature overfitting to noisy pseudo-labels under large domain shifts, degrading adaptation quality from the first training step.

Figure 1: Counterfactual Attention-based Feature Consistency (CAFC). CAFC enforces feature-level consistency between representations computed under learned attention and counterfactual attention perturbations, encouraging robustness to attention drift.
We propose DGA-CAFC, a two-module framework that addresses both failure modes (Fig. 2). The Counterfactual Attention-based Feature Consistency (CAFC) module enforces stability in attention-conditioned features by minimizing the discrepancy between representations computed under the model’s learned attention map and those computed under three counterfactual-inspired normalised attention perturbations: a uniform map that removes all focal structure, a random map that injects noise, and a reversed map that inverts saliency. Minimising this discrepancy is analogous to Lipschitz-style regularization in attention-conditioned feature space: it reduces the sensitivity of the learned representation to the specific attention weight configuration, encouraging domain-robust features that do not depend on source-specific attention patterns. Critically, CAFC requires no target labels and operates on attention outputs, making it directly applicable in both SFDA and DG settings without architectural modification. The Domain-Gap Aware Source Model Selection (DGASS) module addresses the SFDA initialisation problem by estimating target domain gap severity from unlabeled target prediction entropy and selecting the source model variant between a sharp, confident variant and a smoother, more conservative one. Our contributions can be summarized as follows:
- We propose CAFC, an attention-stability regularizer that operates without target labels and transfers across settings, functioning within the SFDA adaptation and as a source-training regularizer in domain generalization.
- We propose DGASS, an entropy-guided source model selection mechanism for SFDA that requires no target labels and acts before adaptation begins, selecting the source variant whose confidence calibration matches the estimated domain gap.
- We extend CAFC to domain generalization as a lightweight source-training regularizer, demonstrating that attention-stability regularization improves multiple standard DG objectives without requiring any target data during training.
- Extensive experiments and analysis are conducted across multiple SFDA and DG benchmarks, with thorough ablation studies provided to justify each design choice and validate the contribution of each proposed module.
Attention in Domain Adaptation. Transformer backbones [3, 16] now underpin many domain-adaptive models [27, 21], with cross-attention and patch-mix strategies exploited for cross-domain transfer [26, 34]. These approaches utilise attention for domain transfer but do not regularise the stability of attention-conditioned representations when source-learned attention maps are applied to out-of-distribution target data. Counterfactual and Causal Learning. Counterfactual attention has been applied to fine-grained recognition by evaluating causal relationships between attention regions and predictions [18, 31]. Unlike these methods, which refine attention for within-domain recognition, CAFC uses counterfactual-inspired perturbations as stress tests for cross-domain feature stability, operating without any target supervision. Domain Generalization. DG methods train solely on source domains and evaluate on unseen targets [4]. Representative objectives include feature alignment (CORAL [20], MMD [23]), interpolation regularisation (Mixup [32]), and distributionally robust optimisation [19, 10]. None impose constraints on attention stability; CAFC is orthogonal to each and can be added as a lightweight source-training regularizer without modifying the base objective.

Figure 2: Overview of the proposed DGA-CAFC framework. Source training produces two source candidates with complementary attention behavior. DGASS selects the source candidate according to target prediction entropy, and CAFC regularizes target adaptation by enforcing consistency between learned and counterfactual attention-conditioned features (best view in color).
3 Methodology
3.1 Problem Formulation
Let denote a source model pre-trained on a labeled source domain and frozen thereafter. In source-free domain adaptation (SFDA), a student model is initialised from and adapted to an unlabeled target domain without accessing . An EMA teacher provides soft supervision. The parameters are updated as a moving average of , yielding temporally stable pseudo-label predictions during adaptation. The adaptation objective is:
where is fully defined in Sec. 3.5. We denote the -class softmax output at target sample as .
3.2 Framework Overview
DGA-CAFC addresses two distinct failure modes of SFDA through two complementary modules (Fig. 2). Attention drift, wherein source-learned attention maps shift toward spurious target-domain features is addressed by CAFC (Fig. 1) (Sec. 3.3), which regularises attention-conditioned features throughout adaptation. Domain-gap-agnostic initialisation, wherein a single fixed source model is applied uniformly regardless of domain gap severity, it is addressed by DGASS (Sec. 3.4), which selects the source variant best matched to the target domain’s estimated gap at initialization time. The two modules are architecturally independent: DGASS acts once before training begins whereas CAFC acts at every gradient step.
3.3 Counterfactual Attention-based Feature Consistency
Learned attention and features. Let be the query, key, and value matrices of a self-attention layer over tokens with dimension . The learned attention map and its conditioned feature are:
where each row of is a valid probability distribution over tokens. Under distribution shift, drifts toward target-domain-specific spurious cues, making fragile.
Counterfactual-inspired perturbations. We define three structured attention perturbations, each stressing a distinct type of attention dependency:
\displaystyle\begin{array}[]{@{}lcll@{}}\mathbf{A}_{\mathrm{unif}}[i,j]&=&\dfrac{1}{N},\quad\forall\,i,j,&\text{removes focal structure},\\[4.0pt] \mathbf{A}_{\mathrm{rand}}&=&\mathrm{Norm}(\mathbf{E}),\quad\mathbf{E}\sim\mathcal{U}(0,1),&\text{injects noisy attention},\\[4.0pt] \mathbf{A}_{\mathrm{rev}}&=&\mathrm{Norm}\!\left(\max\!\left(1-\mathbf{A}_{L},\mathbf{0}\right)\right),&\text{reverses salient regions}.\end{array}where denotes row-wise -normalisation, ensuring each map is a valid probability distribution (necessity established in Supplementary). The three perturbations serve as complementary stress tests: removes all discriminative focus, testing whether features remain stable without any attentional guidance; injects noisy attention, testing stability under unreliable focus; and inverts saliency, testing robustness against over-reliance on salient but potentially spurious source-domain regions. Averaging these three maps into produces a maximally uninformative attention distribution with respect to the learned , ensuring that targets the full complement of attention-drift failure modes. The averaged counterfactual attention map and its feature are:
Minimising the discrepancy between and reduces the sensitivity of the representation to the specific attention configuration. This can be viewed as a form of attention-conditional Lipschitz regularization, promoting features that remain stable under attention drift across domains. The CAFC loss is defined as:
operates on the target domain without labels, making it applicable in both SFDA and DG settings. The design rationale for these perturbations as complementary attention-space stress tests is provided in the Supplementary.
3.4 Domain-Gap Aware Source Model Selection
We propose DGASS, a lightweight entropy-guided strategy that selects the source model variant best matched to the estimated severity of the target domain gap, providing a stronger initialisation starting point for SFDA. Source model variants. We construct source candidates by varying only the self-attention softmax formulation. Let denote the raw attention score between tokens and . and denote the two source candidates used by DGASS. The first source candidate, , uses standard scaled-dot-product softmax attention (eq. 8):
This formulation produces sharp and confident attention distributions. We also define an auxiliary weighted-softmax formulation using min–max rescaling. First, the rescaling weight is computed as (eq. 9)
Here, is a small constant for numerical stability. This weighted formulation improves gradient flow and mitigates vanishing gradients in the standard softmax.
The second source candidate, , uses an averaged softmax formulation that combines the standard and weighted attention weights (eq. 11):
Thus, is trained with , while is trained with .
We adopt and in DGASS because they provide complementary initialization behaviour: gives sharp discriminative focus, whereas balances sharpness with gradient stability and yields a smoother alternative.
Domain-gap estimation. We estimate domain gap severity from the prediction entropy of the source model on unlabelled target samples. The per-sample entropy for target sample is:
where . The overall uncertainty of a source model on the target domain is quantified by the average entropy over all target samples:
Low signals confident source predictions, indicating a small domain gap; high signals uncertainty, indicating a large gap.
Entropy-guided selection. Based on the estimated gap severity, DGASS selects the appropriate source variant:
Intuition. When the domain gap is large, a confident (low-entropy) source model risks over-committing to incorrect pseudo-labels, causing rapid error accumulation. Selecting the higher-entropy variant instead encourages cautious adaptation, providing room for gradual self-correction. Conversely, when the gap is small, the confident variant provides reliable pseudo-labels that accelerate convergence. This adaptive selection is evaluated against fixed source-selection strategies in the experiments.
Principled threshold selection. The threshold is determined once per dataset from unlabelled target predictions (no labels required).
Let denote the set of all transfer tasks in the dataset, and let denote the unlabeled target samples for task . We define the automatic entropy threshold as:
The threshold is computed from unlabeled target prediction entropy using Eq. 15. For each transfer task, we compute the average prediction entropy of both source models and retain the smaller entropy value for threshold estimation. The DGASS threshold is set to for Office31, for Office-Home, and for DomainNet40. On DomainNet40, 11 of 12 tasks satisfy , indicating predominantly high-gap transfer tasks. This median-based rule provides an -robust, distribution-free operating point for separating relatively low-gap and high-gap transfers. Additional motivation, robustness properties, and complete entropy statistics are provided in the Supplementary.
3.5 Training Objective
The student is optimised by four complementary losses. The Knowledge Distillation loss aligns the student’s soft predictions with EMA teacher pseudo-labels:
where are soft pseudo-labels generated by . The Classifier loss sharpens decision boundaries using hard pseudo-labels () for confident predictions:
The Information Maximisation loss balances per-sample prediction confidence with marginal class diversity. Let , where denotes the -th class probability and denotes the empirical marginal probability of class . We define
Minimizing the first term encourages confident per-sample predictions, while minimizing the second term is equivalent to maximizing the marginal entropy , thereby discouraging class collapse. The complete adaptation objective is:
The weight on down-weights the teacher signal early in adaptation when pseudo-labels are less reliable; all other loss weights are . The EMA teacher is updated after each student step with momentum
3.6 Extension to Domain Generalization
In the domain generalization (DG) setting, no target data are available during training, making DGASS inapplicable. We therefore apply alone as a lightweight regularizer during source-domain training. The same counterfactual attention perturbations and CAFC loss are computed on source-domain batches without requiring target data. Since the ResNet backbones used here do not natively produce transformer-style attention maps, we append a lightweight self-attention adapter: the 512-dimensional pooled feature is projected into latent tokens, processed by a single self-attention layer, and pooled back to 512 dimensions before classification. We evaluate CAFC under two protocols: a ResNet-18-from-scratch isolation setting and a standard DomainBed-style setting with ImageNet-pretrained ResNet-50. The former isolates the contribution of CAFC from ImageNet pretraining, while the latter enables direct comparison with standard DG evaluations.
4 Experimental Setup
Datasets. For SFDA, we evaluate on Office31, Office-Home, and DomainNet40. Office31 contains three domains (Amazon, Webcam, DSLR) and 31 classes; Office-Home contains four domains (Artistic, ClipArt, Product, Real-World) and 65 classes; DomainNet40 contains four domains (Clipart, Painting, Real, Sketch) and 40 classes. For DG, we evaluate on PACS and VLCS under the standard leave-one-domain-out protocol.
Implementation details. For SFDA, we use an ImageNet-pretrained ResNet-50 backbone followed by transformer attention layers, a bottleneck layer, and a classifier. Source models are trained with label-smoothed cross-entropy using . During adaptation, the DGASS-selected source hypothesis initializes both the teacher and student models. The EMA teacher uses momentum . The student is optimized using SGD with learning rate , momentum , and weight decay . Images are resized to , batch size is , and adaptation runs for epochs. The loss weights are fixed as for CAFC, for information maximization, for knowledge distillation, and for cross-entropy. The DGASS thresholds are set without target labels: for Office31, for Office-Home, and for DomainNet40. For DG, we use ResNet-18 trained from scratch as well as ImageNet pretrained ResNet-50. A lightweight self-attention adapter maps the 512-dimensional backbone feature into latent tokens to compute the CAFC regularization signal. The CAFC coefficient is fixed as for all DG objectives. All experiments use the same image size, split protocol, and three-seed evaluation. Evaluation. We report top-1 accuracy. SFDA results are averaged over all transfer tasks, while DG results are averaged over held-out target domains. All reported results are mean over three independent seeds; DG tables additionally report standard deviation.
Method AC AP AR CA CP CR PA PC PR RA RC RP Avg. Source Only 59.47 74.32 80.31 64.44 72.72 74.91 69.67 58.10 82.49 76.10 61.40 83.67 71.47 GSDA [5] 61.30 76.10 79.40 65.40 73.30 74.30 65.00 53.20 80.00 72.20 60.60 83.10 70.30 SHOT [14] 57.10 78.10 81.50 68.00 78.20 78.10 67.40 54.90 82.20 73.30 58.80 84.30 71.80 NRC [30] 57.70 80.30 82.00 68.10 79.80 78.60 65.30 56.40 83.00 71.00 58.60 85.60 72.20 AaD [29] 59.30 79.30 82.10 68.90 79.80 79.50 67.20 57.40 83.10 72.10 58.50 85.40 72.70 CoWA-JMDS [12] 56.90 78.40 81.00 69.10 80.00 79.90 67.70 57.20 82.40 72.80 60.50 84.50 72.50 EKS [17] 58.95 79.49 82.86 70.62 80.22 81.48 71.80 57.21 83.76 75.94 62.27 86.30 74.24 TVT [28] 67.10 83.50 87.30 77.40 85.00 85.60 75.60 64.90 86.60 79.10 67.20 88.00 78.90 TransDA [27] 67.50 83.30 85.90 74.00 83.80 84.40 77.00 68.00 87.00 80.50 69.90 90.00 79.30 PLUE† [15] 49.10 73.50 78.20 62.90 73.50 74.50 62.20 48.30 78.60 68.60 51.80 81.50 66.90 C-SFDA [9] 60.30 80.20 82.90 69.30 80.10 78.80 67.30 58.10 83.40 73.60 61.30 86.30 73.50 TPDS [22] 59.30 80.30 82.10 70.60 79.40 80.90 69.80 56.80 82.10 74.50 61.20 85.30 73.50 DPC [24] 59.50 80.60 82.90 69.40 79.30 80.10 67.30 57.20 83.70 73.10 58.90 84.90 73.10 ASM [7] 56.90 79.10 82.90 69.50 79.60 79.70 67.90 55.10 82.60 74.70 60.50 84.80 72.80 CPD [33] 59.10 79.00 82.40 68.50 79.70 79.50 67.90 57.90 82.80 73.80 61.20 84.60 73.00 UCon [25] 61.50 80.50 82.10 69.30 80.80 78.70 67.00 62.20 82.00 72.20 61.90 85.50 73.60 DGA-CAFC (Ours) 69.44 82.95 86.27 76.10 86.39 84.58 78.24 67.17 86.89 79.65 69.48 88.76 79.66
Table 1: Classification accuracy (%) on Office-Home under the source-free domain adaptation protocol.
Method SC SP SR CS CP CR PS PC PR RS RC RP Avg. Source Only 80.22 79.47 84.78 76.12 73.82 84.23 78.30 76.61 89.23 73.08 79.45 84.43 79.98 SHOT [14] 80.50 70.80 88.30 75.50 74.00 88.40 76.20 77.70 89.80 72.80 79.40 75.40 79.10 EKS [17] 81.88 81.44 88.77 78.69 82.91 91.82 78.56 83.62 92.05 77.30 83.54 84.37 83.74 TransDA [27] 85.97 86.31 89.41 82.72 85.42 91.82 83.42 85.37 91.39 81.26 85.84 86.80 86.31 SSRT-B [21] 70.60 62.20 73.20 59.80 60.20 75.80 55.20 61.70 71.40 58.90 69.90 66.00 65.41 DGA-CAFC (Ours) 87.19 89.32 93.47 84.15 85.39 92.13 84.60 85.31 91.56 81.98 87.94 86.91 87.49
Table 2: Classification accuracy (%) on DomainNet40 under the source-free domain adaptation protocol.
Method AD AW DA DW WA WD Avg. Source Only 83.53 85.91 59.74 97.74 64.89 99.60 81.90 SHOT [14] 94.00 90.10 74.70 98.40 74.30 99.90 88.60 3C-GAN [1] 92.70 93.70 75.30 98.50 77.80 99.80 89.60 NRC [30] 96.00 90.80 75.30 99.10 75.00 100.00 89.40 AaD [29] 96.40 92.10 75.00 99.10 76.50 100.00 89.90 CoWA-JMDS [12] 94.40 95.20 76.20 98.50 77.60 99.80 90.30 CAN [8] 95.00 94.50 78.00 99.10 77.00 99.80 90.60 EKS [17] 98.10 96.40 74.50 99.00 75.10 99.80 90.50 TransDA [27] 97.20 95.00 73.70 99.30 79.30 99.60 90.70 PLUE† [15] 89.20 88.40 72.80 97.10 69.60 97.90 85.80 C-SFDA [9] 96.20 93.90 77.30 98.80 77.90 99.70 90.50 TPDS [22] 97.10 94.50 75.70 98.70 75.50 99.80 90.20 DPC [24] 95.80 94.50 76.50 98.90 76.80 100.00 90.50 ASM [7] 96.00 95.10 75.30 98.70 77.20 100.00 90.40 CPD [33] 96.60 94.20 77.30 98.20 78.30 100.00 90.80 UCon [25] 94.80 95.40 77.10 98.90 77.10 100.00 90.60 DGA-CAFC (Ours) 97.59 96.48 77.78 99.00 79.06 100.00 91.65
Table 3: Classification accuracy (%) on Office31 under the SFDA.
5 Experimental Results
Method Backbone Art Cartoon Photo Sketch Avg. ERM R-18 39.731.65 51.683.29 66.750.73 39.553.18 49.431.59 ERM+CAFC R-18 39.991.85 54.762.99 65.492.77 41.8810.12 50.531.70 (+1.10) ERM R-50 80.552.57 76.072.95 97.720.10 62.146.76 79.121.49 ERM+CAFC R-50 81.741.57 77.162.87 97.960.33 69.022.26 81.471.08 (+2.35) CORAL [20] R-18 35.952.20 50.511.65 55.533.37 41.110.17 45.781.70 CORAL+CAFC R-18 40.103.76 51.862.33 52.651.44 43.714.61 47.082.37 (+1.30) CORAL R-50 80.211.29 77.391.85 95.670.71 72.732.10 81.500.50 CORAL+CAFC R-50 81.853.87 75.600.91 96.260.87 75.361.78 82.270.43 (+0.77) Mixup [32] R-18 35.848.22 47.724.35 53.595.90 35.0511.23 43.055.52 Mixup+CAFC R-18 40.303.25 51.663.06 57.966.77 39.8210.90 47.442.46 (+4.39) Mixup R-50 86.251.09 79.360.15 96.171.51 72.743.96 83.631.31 Mixup+CAFC R-50 87.502.29 78.240.17 97.261.06 75.172.25 84.541.30 (+0.91) GroupDRO [19] R-18 34.293.20 51.352.96 48.683.32 46.015.08 45.081.85 GroupDRO+CAFC R-18 39.401.93 53.500.91 53.573.48 50.402.31 49.221.06 (+4.14) GroupDRO R-50 80.130.73 74.391.43 96.570.43 74.657.02 81.431.94 GroupDRO+CAFC R-50 80.784.46 77.503.59 96.030.73 77.462.74 82.941.93 (+1.51) VREx [10] R-18 37.172.65 53.312.08 55.432.38 47.313.67 48.311.75 VREx+CAFC R-18 41.574.17 49.232.50 53.795.28 45.2910.36 47.473.83 (-0.84) VREx R-50 78.193.37 74.694.49 95.470.30 70.758.65 79.772.86 VREx+CAFC R-50 79.512.61 75.782.54 95.290.78 72.760.37 80.840.31 (+1.07)
Table 4: DG results on PACS with ResNet-18-from-scratch and pretrained ResNet-50. Parentheses denote gains over the baseline.
Method Backbone Caltech101 LabelMe SUN09 VOC2007 Avg. ERM R-18 73.103.16 55.172.02 48.033.77 49.401.47 56.421.64 ERM+CAFC R-18 76.093.23 55.463.80 47.863.04 48.464.87 56.971.84 (+0.55) ERM R-50 98.040.68 65.750.98 74.010.80 71.363.33 77.290.41 ERM+CAFC R-50 98.030.23 67.440.38 77.251.58 78.972.70 80.420.49 (+3.13) CORAL [20] R-18 73.072.23 55.410.93 49.274.03 43.930.81 55.420.56 CORAL+CAFC R-18 73.802.44 56.252.36 49.692.75 48.010.29 56.940.81 (+1.52) CORAL R-50 98.260.57 65.130.52 75.100.67 72.381.82 77.720.11 CORAL+CAFC R-50 98.530.41 66.200.96 74.612.67 76.181.01 78.880.68 (+1.16) Mixup [32] R-18 71.141.42 57.673.31 50.773.49 47.011.81 56.650.89 Mixup+CAFC R-18 75.571.22 57.671.20 51.522.25 47.632.41 58.100.36 (+1.45) Mixup R-50 98.570.11 65.611.87 73.551.64 77.581.37 78.830.34 Mixup+CAFC R-50 98.650.23 67.071.62 76.361.00 76.662.11 79.690.58 (+0.86) GroupDRO [19] R-18 76.070.76 54.615.07 51.291.40 46.302.18 57.061.79 GroupDRO+CAFC R-18 76.872.90 58.412.46 52.754.15 47.420.65 58.860.15 (+1.80) GroupDRO R-50 98.520.51 65.040.35 75.501.09 70.021.12 77.270.29 GroupDRO+CAFC R-50 98.560.25 66.032.00 75.500.90 74.931.75 78.760.58 (+1.49) MMD [13] R-18 73.591.13 54.430.97 49.283.42 45.451.45 55.690.91 MMD+CAFC R-18 76.402.00 55.361.79 51.935.49 46.501.91 57.551.62 (+1.86) MMD R-50 97.790.82 65.510.23 74.833.11 72.371.17 77.630.73 MMD+CAFC R-50 98.070.82 67.750.60 75.251.16 76.000.94 79.270.60 (+1.64)
Table 5: DG results on VLCS with ResNet-18-from-scratch and pretrained ResNet-50. Parentheses denote gains over the baseline.
We evaluate our method in two complementary settings: source-free domain adaptation (SFDA), where unlabeled target data are available at adaptation time, and domain generalization (DG), where target data are entirely withheld during training. SFDA experiments evaluate the complete framework (CAFC + DGASS), while DG experiments isolate CAFC as a plug-in attention-drift regularizer applied to standard DG objectives without access to target data. Source-Free Domain Adaptation Results DomainNet40. Table 2 reports classification accuracy on DomainNet40, a challenging large-scale benchmark comprising four domains (Clipart, Painting, Real, Sketch) and 40 classes. Our method achieves an average accuracy of 87.49%, improving over the strongest baseline TransDA [27] by +1.18 %. Consistent gains are observed across the majority of transfer pairs; notably, improves by +4.06 % and by +1.18 %, reflecting the benefit of attention-drift regularization under large style shifts. We note that the gain on DomainNet40 is driven primarily by the CAFC module , the uniformly high domain gap of this benchmark causes DGASS to correctly default to the high-entropy source variant across 11 of 12 tasks.
Office31. Table 3 lists results on Office31, which comprises three domains (Amazon, Webcam, DSLR) and 31 classes. Our method attains an average accuracy of 91.65%, surpassing all compared methods. Relative to the recent SFDA baselines, our method outperforms NRC [30] by +2.30 %, AaD [29] by +1.80 %, and CoWA-JMDS [12] by +1.37 %. Task-level analysis confirms our method achieves best or second-best accuracy on five of six transfer tasks, including the most competitive pair where accurate adaptation of dense appearance differences benefits from DGASS-driven domain-gap-aware initialization.
Office-Home. Table 1 presents results on the more challenging Office-Home benchmark (four domains, 65 classes, 12 transfer tasks). Our method achieves the highest average accuracy of 79.66%, narrowly surpassing TransDA (79.30%) and TVT [28] (78.90%) while outperforming recent SFDA specific methods (NRC: 72.20%, AaD: 72.70%, CoWA-JMDS: 72.50%). Task-level inspection reveals our method ranks first on three tasks (, , ) and second on seven further tasks, yielding consistent improvement across diverse cross-domain appearance shifts.
CAFC DGASS Avg. Note 90.64 – Baseline ✓ 91.11 +0.47 DGASS only ✓ 91.01 +0.37 CAFC only ✓ ✓ 91.65 +1.01 Full (interaction +0.17)
Table 6: Ablation study of CAFC and DGASS on Office31. The baseline uses neither module. denotes the absolute improvement over the baseline.
Method Backbone Office31 Avg. Office-Home Avg. SHOT ResNet-50 88.60 71.80 Our ResNet-50+Attn 87.67 70.53 CoWA-JMDS ResNet-50 90.30 72.50 Our ResNet-50+Attn 87.40 71.49 NRC ResNet-50 89.40 72.20 Our ResNet-50+Attn 82.31 64.06 DGA-CAFC Our ResNet-50+Attn 91.65 79.66
Table 7: Backbone-confound check: SFDA baselines on original ResNet-50 and matched ResNet-50+attention backbones.
Domain Generalization Results To evaluate whether CAFC generalizes beyond the source-free adaptation setting, we integrate it as a plug-in regularizer into various representative DG objectives on PACS and VLCS. Since DG provides no target data, DGASS is not applicable; these experiments therefore isolate the contribution of CAFC. We report both the original ResNet-18-from-scratch isolation setting and the standard DomainBed-style ImageNet-pretrained ResNet-50 setting. Results are reported as mean standard deviation over three seeds.
PACS. Table 4 reports results under both protocols on PACS. In the ResNet-18 isolation setting, CAFC improves four of five objectives, with particularly strong gains for Mixup (+4.39%) and GroupDRO (+4.14%), while also reducing seed variance for both objectives. More importantly, under the standard ImageNet-pretrained ResNet-50 protocol, CAFC improves all five objectives. This includes VREx, for which the degradation observed with ResNet-18 is reversed to a +1.07% gain under ResNet-50. Together, these results show that the benefit of CAFC persists under the standard pretrained DG regime and that the isolated negative VREx case does not carry over to this setting. VLCS. Table 5 shows a consistent benefit across both protocols on VLCS dataset. In the ResNet-18 isolation setting, CAFC improves all five objectives and reduces seed variance for several of them, including Mixup and GroupDRO. Under the standard ImageNet-pretrained ResNet-50 protocol, CAFC again improves all five objectives, with the largest gains observed for ERM (+3.13%), MMD (+1.64%), and GroupDRO (+1.49%). This consistency across objectives and backbone settings further supports the robustness of CAFC as a DG regularizer. Overall, the DomainBed-style ResNet-50 results strengthen the DG evidence by showing improvements across all 10 objectivedataset combinations under the standard pretrained protocol. Together with the ResNet-18 isolation results, this indicates that CAFC provides a broadly applicable attention-stability regularization signal across different DG objectives and backbone settings.
6 Analysis
Contribution of CAFC and DGASS Modules. Table 6 reports the Office31 ablation study. The baseline achieves 90.64%, while adding DGASS alone improves accuracy to 91.11% (+0.47 %) and adding CAFC alone improves it to 91.01% (+0.37 %). The full DGA-CAFC framework reaches 91.65%, giving a total gain of +1.01 %. The positive interaction term (+0.17 %) shows that DGASS and CAFC are complementary: domain-gap-aware initialization improves pseudo-label quality, making CAFC regularization more effective during adaptation. This synergy is mechanistically intuitive, a source model initialized with an appropriate confidence level for the target domain produces pseudo-labels of higher quality, which in turn makes CAFC consistency signal more discriminative for adaptation.
Backbone-Confound Analysis. To isolate backbone effects from the algorithmic contribution, we re-run SHOT, CoWA-JMDS, and NRC on the same ResNet-50+attention backbone used by DGA-CAFC, using each method’s official code and published hyperparameters. Only the same lightweight self-attention module is added, with no other architectural or training changes. Compared with the original ResNet-50 results in Table 7, adding attention alone degrades all three baselines, most severely NRC (% on Office31 and % on Office-Home). This is consistent with evidence that transformer relevance maps can rely on spurious background regions under distribution shift, while regularizing such signals can improve out-of-distribution robustness [2]. Thus, attention capacity alone is insufficient; its benefit depends on regularizing the resulting attention-conditioned features. On the identical backbone, DGA-CAFC substantially outperforms all re-run baselines on both datasets, showing that its gains cannot be attributed to the stronger backbone alone.
Ablation of loss components. Table 8 reports the contribution of each adaptation loss while keeping CAFC and DGASS fixed. Removing any loss degrades performance, confirming that IM, KD, and CL provide complementary supervision during target adaptation. The full objective achieves the best Office31 accuracy of .
Method IM KD CL CAFC DGASS Office-31 w/o IM – ✓ ✓ ✓ ✓ 90.28 w/o KD ✓ – ✓ ✓ ✓ 90.41 w/o CL ✓ ✓ – ✓ ✓ 90.58 Full (DGA-CAFC) ✓ ✓ ✓ ✓ ✓ 91.65
Table 8: Loss-component ablation on Office31. CAFC and DGASS are kept fixed, while each of the losses are removed.
0.0 0.2 0.78 0.8 1.6 1.7 Avg. 90.01 90.01 91.65 91.53 91.53 91.46
Table 9: Sensitivity of DGA-CAFC to the DGASS threshold on Office31. Accuracy remains stable over a broad range around the selected value.
Method AC AP AR CA CP CR PA PC PR RA RP RC Avg. TransDA [27] .2808 .2123 .1867 .1798 .2007 .2043 .1833 .2957 .2101 .1611 .2885 .1955 .2166 DGA-CAFC .2237 .0403 .0359 .1519 .1772 .0384 .1253 .2459 .1906 .0191 .2731 .0198 .1284
Table 10: Expected Calibration Error on Office-Home.
Adaptive selection outperforms fixed strategies. Table 11 compares DGASS with fixed low- and high-entropy source selection. On Office31, DGASS achieves 91.65%, compared with 91.40% and 91.00% for fixed-low and fixed-high selection, respectively. The advantage is larger on Office-Home, where DGASS reaches 79.66% versus 77.43% and 74.90% for fixed-low and fixed-high selection. On DomainNet40, where 11 of 12 transfer tasks are identified as high-gap, DGASS achieves 87.49% compared with 85.89% under fixed-low selection. These results show that the preferred source initialization depends on domain-gap severity rather than a single fixed choice. Full per-task selections and entropy values are provided in the Supplementary.
Dataset Fixed low Fixed high DGASS Office31 91.40 91.00 91.65 Office-Home 77.43 74.90 79.66 DomainNet40 85.89 86.23 87.49
Table 11: Fixed source-model selection vs. adaptive DGASS.
Principled threshold selection. The threshold is selected by a one-time unlabeled preliminary sweep over target predictions using the auto- rule: is set as the median of per-task average entropy observed across the target domain under either source variant.
Backbone Generalization to Transformers. To validate the proposed approach beyond the hybrid ResNet-50+attention design, we evaluate native transformer backbones in both DG and SFDA (Table 12). In DG on VLCS, CAFC improves ERM with Swin-T by +1.59% and with ViT-B/16 by +1.46%. In SFDA on Office31, DGA-CAFC with ViT-B/16 reaches 93.43%, outperforming SHOT-ViT (91.40%) by +2.03%. Together, these ablation results show that the proposed method remains effective with native transformer backbones across both DG and SFDA, and is not tied to the ResNet-50+attention architecture.
| DG: VLCS Backbone ERM +CAFC Gain ResNet-50 77.29 80.42 +3.13 Swin-T 79.98 81.57 +1.59 ViT-B/16 79.12 80.58 +1.46 | SFDA: Office31 Method Backbone Avg. SHOT ResNet-50 88.60 SHOT ResNet-50+Attn 87.67 SHOT ViT-B/16 91.40 DGA-CAFC ResNet-50+Attn 91.65 DGA-CAFC ViT-B/16 93.43 |
|---|
Table 12: Native-transformer validation in DG and SFDA.
Sensitivity to the DGASS Threshold . Table 3 reports DGA-CAFC performance across different values of on Office31. Peak accuracy is achieved at , which closely matches the value of derived from the median rule, confirming that the data-driven threshold selection recovers the optimal operating point without label access. Performance remains within % for , indicating robustness to the precise threshold value once it lies within the appropriate entropy range. At extreme values (, ), all tasks are classified as high-gap and selection collapses to a fixed strategy, causing performance to drop.
Calibration Analysis. Table 10 reports Expected Calibration Error (ECE) on Office-Home, measuring how well predicted confidence aligns with accuracy. DGA-CAFC reduces ECE from 0.2166 (TransDA) to 0.1284. Improved calibration benefits SFDA by making the entropy signal used by DGASS more reliable and by reducing the influence of over-confident pseudo-labels during self-training.
Transferability of CAFC to DG. The DG results in Tables, 4 and 5 show that CAFC transfers beyond SFDA. Across interpolation-based, robust-optimization, feature-alignment, and ERM objectives, CAFC improves all 10 objectivedataset combinations under the standard pretrained ResNet-50 protocol. This suggests that CAFC addresses a common source of domain-shift sensitivity rather than acting as a correction for a single training objective. Statistical significance. Paired seed-level tests confirm significant gains on PACS and VLCS, both ; full statistics are provided in the Supplementary. Direct attention-drift validation. On PACS, CAFC reduces the mean in-/out-of-domain attention-map divergence from 0.0357 to 0.0181, providing direct evidence that CAFC suppresses attention drift under domain shift. Full per-domain results are provided in the Supplementary. Variance reduction in several objectives. Beyond mean accuracy gains, CAFC reduces seed variance for selected DG objectives. In the ResNet-18 isolation setting, the standard deviation decreases for GroupDRO from 1.85 to 1.06 and for Mixup from 5.52 to 2.46 on PACS; on VLCS, it decreases for GroupDRO from 1.79 to 0.15 and for Mixup from 0.89 to 0.36. These reductions suggest improved training stability for these objectives, while full seed-level statistics are provided in the Supplementary.


Figure 3: Grad-CAM visualization for Office31 D→A.


Figure 4: t-SNE visualization for Office31 D→A.
Qualitative Analysis. Fig. 3 shows that CAFC broadens attention beyond narrowly concentrated regions and shifts focus toward more complete object structure on Office31 DA. This qualitatively supports reduced reliance on domain-specific cues. Fig. 1 shows that DGA-CAFC produces more compact target clusters and clearer inter-class separation than the source-only model, consistent with improved feature organization under domain shift.
7 Conclusion
We presented DGA-CAFC, a source-free domain adaptation framework designed to address two key limitations: attention drift under domain shift and domain-gap agnostic source initialization. CAFC enforces feature consistency under attention perturbations, while DGASS selects a source model variant using target prediction entropy to better match the estimated domain gap. Across Office31, Office-Home, and DomainNet40, DGA-CAFC consistently improves SFDA performance and calibration, with complementary gains from both modules. CAFC also transfers to the DG setting, improving standard DG objectives on PACS and VLCS without target data. Results suggest that attention-stability regularization is a useful principle for domain-robust recognition.
Acknowledgment
Shivangi Rai gratefully acknowledges the financial support provided through the Visvesvaraya PhD Fellowship by the Ministry of Electronics and Information Technology (MeitY), Government of India.
References
[1] P. Agarwal, D. P. Paudel, J. Zaech, and L. Van Gool (2022) Unsupervised robust domain adaptation without source data. In Proceedings of the IEEE/CVF winter conference on applications of computer vision, pp. 2009–2018. Cited by: Table 3.
[2] H. Chefer, I. Schwartz, and L. Wolf (2022) Optimizing relevance maps of vision transformers improves robustness. Advances in Neural Information Processing Systems 35, pp. 33618–33632. Cited by: §6.
[3] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. (2020) An image is worth 16x16 words: transformers for image recognition at scale. arXiv preprint arXiv:2010.11929. Cited by: §1, §2.
[4] I. Gulrajani and D. Lopez-Paz (2020) In search of lost domain generalization. arXiv preprint arXiv:2007.01434. Cited by: §1, §2.
[5] L. Hu, M. Kan, S. Shan, and X. Chen (2020) Unsupervised domain adaptation with hierarchical gradient synchronization. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 4043–4052. Cited by: Table 1.
[6] P. J. Huber and E. M. Ronchetti (2011) Robust statistics. John Wiley & Sons. Cited by: §5.
[7] M. Jing, J. Li, K. Lu, L. Zhu, and H. T. Shen (2024) Visually source-free domain adaptation via adversarial style matching. IEEE Transactions on Image Processing 33, pp. 1032–1044. Cited by: Table 1, Table 3.
[8] G. Kang, L. Jiang, Y. Yang, and A. G. Hauptmann (2019) Contrastive adaptation network for unsupervised domain adaptation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 4893–4902. Cited by: Table 3.
[9] N. Karim, N. C. Mithun, A. Rajvanshi, H. Chiu, S. Samarasekera, and N. Rahnavard (2023) C-sfda: a curriculum learning aided self-training framework for efficient source free domain adaptation. In 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 24120–24131. Cited by: Table 1, Table 3.
[10] D. Krueger, E. Caballero, J. Jacobsen, A. Zhang, J. Binas, D. Zhang, R. Le Priol, and A. Courville (2021) Out-of-distribution generalization via risk extrapolation (rex). In International conference on machine learning, pp. 5815–5826. Cited by: §2, Table 4.
[11] J. Law (1986) Robust statistics—the approach based on influence functions. Wiley Online Library. Cited by: §5.
[12] J. Lee, D. Jung, J. Yim, and S. Yoon (2022) Confidence score for source-free unsupervised domain adaptation. In International conference on machine learning, pp. 12365–12377. Cited by: §1, §2, Table 1, Table 3, §5.
[13] A. Li, J. Wu, Y. Liu, and L. Li (2024) Bridging the synthetic-to-authentic gap: distortion-guided unsupervised domain adaptation for blind image quality assessment. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 28422–28431. Cited by: Table 5.
[14] J. Liang, D. Hu, and J. Feng (2020) Do we really need to access the source data? source hypothesis transfer for unsupervised domain adaptation. In International conference on machine learning, pp. 6028–6039. Cited by: §1, §1, §2, Table 1, Table 2, Table 3.
[15] M. Litrico, A. Del Bue, and P. Morerio (2023) Guiding pseudo-labels with uncertainty estimation for source-free unsupervised domain adaptation. In 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 7640–7650. Cited by: Table 1, Table 3.
[16] Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo (2021) Swin transformer: hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 10012–10022. Cited by: §1, §2.
[17] S. Rai, R. S. Thakur, K. Jangid, and V. K. Kurmi (2025) Label calibration in source free domain adaptation. In 2025 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 6446–6455. Cited by: Table 1, Table 2, Table 3.
[18] Y. Rao, G. Chen, J. Lu, and J. Zhou (2021) Counterfactual attention learning for fine-grained visual categorization and re-identification. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 1025–1034. Cited by: §2, §2, §8.
[19] S. Sagawa, P. W. Koh, T. B. Hashimoto, and P. Liang (2019) Distributionally robust neural networks for group shifts: on the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731. Cited by: §1, §2, Table 4, Table 5.
[20] B. Sun and K. Saenko (2016) Deep coral: correlation alignment for deep domain adaptation. In European conference on computer vision, pp. 443–450. Cited by: §2, Table 4, Table 5.
[21] T. Sun, C. Lu, T. Zhang, and H. Ling (2022) Safe self-refinement for transformer-based domain adaptation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 7191–7200. Cited by: §1, §2, §2, Table 2.
[22] S. Tang, A. Chang, F. Zhang, X. Zhu, M. Ye, and C. Zhang (2024) Source-free domain adaptation via target prediction distribution searching. International journal of computer vision 132 (3), pp. 654–672. Cited by: Table 1, Table 3.
[23] R. Volpi, H. Namkoong, O. Sener, J. Duchi, V. Murino, and S. Savarese (2018) Generalizing to unseen domains via adversarial data augmentation. Advances in neural information processing systems 31. Cited by: §2.
[24] H. Xia, S. Xia, and Z. Ding (2024) Discriminative pattern calibration mechanism for source-free domain adaptation. In 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 23648–23658. Cited by: Table 1, Table 3.
[25] G. Xu, H. Guo, L. Yi, C. Ling, B. Wang, and G. Yi (2025) Revisiting source-free domain adaptation: a new perspective via uncertainty control. In International Conference on Learning Representations, Vol. 2025, pp. 92900–92939. Cited by: Table 1, Table 3.
[26] T. Xu, W. Chen, P. Wang, F. Wang, H. Li, and R. Jin (2021) Cdtrans: cross-domain transformer for unsupervised domain adaptation. arXiv preprint arXiv:2109.06165. Cited by: §2.
[27] G. Yang, H. Tang, Z. Zhong, M. Ding, L. Shao, N. Sebe, and E. Ricci (2021) Transformer-based source-free domain adaptation. arXiv preprint arXiv:2105.14138. Cited by: §1, §2, §2, Table 1, Table 2, Table 3, §5, Table 10.
[28] J. Yang, J. Liu, N. Xu, and J. Huang (2023) Tvt: transferable vision transformer for unsupervised domain adaptation. In 2023 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 520–530. Cited by: §2, Table 1, §5.
[29] S. Yang, S. Jui, J. Van De Weijer, et al. (2022) Attracting and dispersing: a simple approach for source-free domain adaptation. Advances in Neural Information Processing Systems 35, pp. 5802–5815. Cited by: §1, §2, Table 1, Table 3, §5.
[30] S. Yang, J. Van de Weijer, L. Herranz, S. Jui, et al. (2021) Exploiting the intrinsic neighborhood structure for source-free domain adaptation. Advances in neural information processing systems 34, pp. 29393–29405. Cited by: §1, §2, Table 1, Table 3, §5.
[31] N. Yu, L. Chen, X. Yi, and J. Huang (2025) Attention learning with counterfactual intervention based on feature fusion for fine-grained feature learning. Digital Signal Processing 163, pp. 105215. Cited by: §2, §8.
[32] H. Zhang, M. Cisse, Y. N. Dauphin, and D. Lopez-Paz (2017) Mixup: beyond empirical risk minimization. arXiv preprint arXiv:1710.09412. Cited by: §2, Table 4, Table 5.
[33] L. Zhou, N. Li, M. Ye, X. Zhu, and S. Tang (2024) Source-free domain adaptation with class prototype discovery. Pattern recognition 145, pp. 109974. Cited by: Table 1, Table 3.
[34] J. Zhu, H. Bai, and L. Wang (2023) Patch-mix transformer for unsupervised domain adaptation: a game perspective. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 3561–3571. Cited by: §2.
Supplementary Material of Attention Drift Regularization with Adaptive Initialization for Domain-Robust Visual Recognition
1 Quantification of the Attention Drift
To directly quantify attention drift, we measure the divergence between learned attention distributions on the training domains and each unseen held-out domain in the DG setting. For each attention head, we compute the mean learned attention map over the training domains, , and over the corresponding held-out domain, . Attention drift is then defined as
Since each attention row is a probability distribution, , with lower values indicating more stable attention across domain shift.
We compare ERM and ERM+CAFC using otherwise identical training and the same training-domain validation-based checkpoint selection. The analysis is performed on PACS for all four leave-one-domain-out settings (Art, Cartoon, Photo, and Sketch held out in turn), using seed 0. As shown in Table 1, CAFC reduces attention divergence for every held-out domain. Averaged across the four targets, decreases from 0.0357 with ERM to 0.0181 with ERM+CAFC. This provides direct quantitative evidence that CAFC yields more domain-stable learned attention under distribution shift.
Held-out domain ERM (no CAFC) ERM+CAFC Art 0.0282 0.0144 Cartoon 0.0367 0.0172 Photo 0.0307 0.0145 Sketch 0.0471 0.0262 Mean 0.0357 0.0181
Table 1: Direct quantification of attention drift on PACS using in-domain vs. held-out-domain attention-map divergence. Lower indicates more stable attention across domain shift.
2 Objective-Direction Analysis: CAL [18] vs. CAFC
Although CAFC uses counterfactual-inspired attention perturbations, its objective is opposite to supervised counterfactual-attention methods such as CAL. To test whether this distinction is empirically meaningful, we compare CAFC with an attention-sensitivity variant that maximizes, rather than minimizes, the learned-vs-counterfactual feature discrepancy. As shown in Table 2, maximizing this discrepancy reduces Office31 accuracy to , below the baseline SFDA result of . In contrast, CAFC improves the baseline to , and the full DGA-CAFC framework reaches . This confirms that the benefit does not come merely from introducing counterfactual perturbations, but from using them as a feature-stability regularizer under domain shift.
Comparison Method / Variant Office31 Avg. CAL vs. CAFC Baseline SFDA 90.64 Attention-sensitivity: maximize feature gap 86.52 CAFC: minimize feature gap 91.01 DGA-CAFC: CAFC+DGASS 91.65
Table 2: Objective-direction ablation distinguishing CAFC from CAL.
3 Detailed explanation of Self-labeling Losses
Self-labeling losses leverage the model’s own outputs to provide supervision on unlabeled target domain data. The combination of these losses, knowledge distillation for soft alignment, information maximization for confident and di- verse predictions, and cross-entropy with hard pseudo- labels helps to effectively adapt the model to new data dis- tributions, enhancing its generalization capabilities.
3.1 Knowledge Distillation Loss ()
The Knowledge Distillation loss guides the student model to mimic the output distribution of a teacher model. It is defined as the cross-entropy between the soft predictions of the student model and the pseudo-labels generated by the teacher model:
Here, denotes the number of classes, represents the target sample, and is the teacher prediction for class . This loss encourages the student to align its class probability predictions with those of the teacher, thus transferring knowledge effectively.
3.2 Information Maximization Loss ()
The Information Maximization loss is designed to enhance the confidence and diversity of the student model’s predictions. It combines an entropy minimization term and a marginal entropy maximization term:
In this equation, denotes the softmax function applied to the student model’s output logits , and represents the estimated marginal class distribution across the target domain. The first term encourages low-entropy (confident) predictions for individual samples, while the second term promotes high entropy over the marginal class distribution to avoid collapsed predictions that favor only a few classes. Together, these terms balance confidence and diversity, improving the robustness of the model on unlabeled data.
3.3 Cross-Entropy Loss ()
In cases where the source data distribution is similar to the target, we want to leverage the learning through pseudo label prediction as it does not contribute to the negative transfer. The Cross-Entropy loss with hard pseudo labels uses the predicted class labels obtained by taking the argmax of the student’s output probabilities as the ground truth for the unlabeled samples:
This loss treats the model’s confident predictions as hard labels to supervise itself, promoting consistency in the decision boundaries. It is particularly useful when the model’s predictions are reliable enough to serve as ground truth.
4 Necessity of Row-Normalisation for Counterfactual Attention Maps
We establish that row-wise -normalisation of the counterfactual attention maps , , and is necessary for to measure directional feature consistency rather than a scale artifact. Row-sum analysis of unnormalised maps. Let denote the sequence length. The learned attention map satisfies for all rows by construction. The three unnormalised counterfactual maps have row sums:
None of these equals , so the three maps are not valid probability distributions over tokens.
Scale contamination without normalisation.
Define the unnormalised aggregate:
with per-row sum . For typical vision transformer sequences ( for ViT/16 on ), . Since where is the row-normalised version, the unnormalised counterfactual feature is:
The unnormalised loss therefore expands as:
The term grows as and depends only on the scalar row-sum magnitude , not on the attention direction. Minimising therefore drives (scale collapse) rather than pulling toward , and the gradient with respect to model parameters is dominated by this scale term, providing no useful signal about directional feature consistency.
Normalisation restores the intended objective.
After applying , all four maps are valid probability distributions over the tokens with unit row sums. The counterfactual feature is a proper weighted average of the value rows under a maximally uninformative attention distribution. then measures the change in the feature vector solely due to the difference in attention direction between the learned and counterfactual maps, with no scale confound. This is the quantity that directly reflects attention-induced feature instability under distribution shift and constitutes an appropriate training signal for domain-robust feature learning.
5 Robustness Properties of the DGASS Threshold
Equation (15) in the main paper defines the DGASS threshold as the median of the per-task minimum entropy:
We motivate this choice as a robust, label-free thresholding rule.
Median as an -robust statistic. For any finite set of scalar values , any median minimizes the sum of absolute deviations [6, 11]:
In contrast, the arithmetic mean minimizes squared deviations and is therefore more sensitive to extreme entropy values. This distinction is important for cross-task entropy statistics, where transfer tasks can have substantially different domain-gap severity. Using the median gives each task equal rank-based influence and provides an outlier-resistant operating point for separating relatively low-gap and high-gap transfers.
Distribution-free validity. The median does not require a parametric assumption about the shape of the cross-task entropy distribution. This is appropriate for DGASS because the threshold must be computed without target labels or target validation accuracy. Parametric alternatives, such as fitting a Gaussian model or choosing a distribution-specific percentile, would require estimating additional distributional parameters from the same unlabeled entropy statistics. The median rule avoids this extra modeling assumption while remaining fully label-free.
0.0 0.2 0.78 0.8 1.6 1.7 Avg. 90.01 90.01 91.65 91.53 91.53 91.46
Table 3: Sensitivity of DGA-CAFC to the DGASS threshold on Office31. Accuracy remains stable over a broad range around the selected value.
Empirical robustness as complementary evidence. The threshold-sensitivity analysis in Table 3 shows that Office31 accuracy varies by less than percentage points for , a range that includes the median-derived value. This indicates that DGASS does not require a precisely tuned threshold in this setting. The role of the median rule is therefore not to identify a single sharply optimal value, but to provide a reliable validation-free operating point within a stable range of threshold values.
Model AD AW DA DW WA WD 0.78 0.76 1.78 0.49 1.63 0.27 0.75 0.73 1.83 0.50 1.60 0.29
Table 4: Entropy values for different domain adaptation tasks on the Office-31 dataset
| Model | AC | AP | AR | CA | CP | CR | PA | PC | PR | RA | RP | RC |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1.32 | 1.08 | 0.92 | 1.27 | 1.02 | 1.03 | 1.26 | 1.35 | 0.80 | 0.83 | 1.03 | 0.53 | |
| 1.25 | 0.97 | 0.84 | 1.25 | 1.03 | 1.01 | 1.23 | 1.29 | 0.80 | 0.82 | 1.01 | 0.51 |
Table 5: Prediction entropy values for Office-Home transfer tasks.
| Model | SC | SP | SR | CS | CP | CR | PS | PC | PR | RS | RC | RP |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.53 | 0.56 | 0.48 | 0.91 | 1.22 | 1.00 | 0.50 | 0.55 | 0.39 | 0.33 | 0.31 | 0.27 | |
| 0.54 | 0.57 | 0.49 | 0.94 | 1.23 | 1.02 | 0.48 | 0.52 | 0.38 | 0.32 | 0.29 | 0.25 |
Table 6: Prediction entropy values for DomainNet40 transfer tasks.
Model AD AW DA DW WA WD Domain Gap from 0.78 0.76 1.78 0.49 1.63 0.27
Table 7: Entropy values (Domain Gap) for different adaptation tasks on Office-31 from model
Task Model Selected
Table 8: Model selection through DGASS module on office31 dataset.
6 Entropy Values for Model selection
The entropy values utilized for model selection is reported in Table 4, 5 and 6 for office31, office-home and domainnet40 dataset respectively. For each dataset we report the entropy values from both variants of the source model and .
7 Example of Model Selection
Example of model selection on office31 dataset. First step is to analyze the domain gap for each task based on the entropy from any of the two models and . Here, for office31 dataset, we report the prediction entropy in Table 7. The threshold
| Method | AC | AP | AR | CA | CP | CR | PA | PC | PR | RA | RC | RP | Avg. |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variant-1 | 68.77 | 81.78 | 85.36 | 75.94 | 85.22 | 85.24 | 77.79 | 67.29 | 86.55 | 80.06 | 70.03 | 88.53 | 79.40 |
| Variant-2 | 65.77 | 82.29 | 84.53 | 73.18 | 82.32 | 83.34 | 76.68 | 66.78 | 85.91 | 79.52 | 68.09 | 89.07 | 78.12 |
| Variant-3 | 67.06 | 82.07 | 85.01 | 75.36 | 83.49 | 83.93 | 76.64 | 66.64 | 86.00 | 79.69 | 69.03 | 88.60 | 78.62 |
Table 9: Generalization ability of three variants of source model on Office-Home dataset.
Tasks with high domain gap are (, and ). Tasks with low domain gap are (, and ).
Now, if the domain gap is higher than or equal to threshold 0.78 (High domain gap tasks), select high entropy model otherwise select low entropy model based on Table 4. The results are reported in Table 8
8 Design Rationale for Counterfactual Perturbations
The three perturbations in Eq. (4) are designed to target structurally distinct failure modes of attention under distribution shift. Inspired by counterfactual attention interventions used in prior attention-learning work [18, 31], we use a small set of complementary perturbations rather than searching over the full space of possible attention corruptions. These perturbations stress-test different forms of attention instability that can arise when source-learned attention patterns are applied to shifted target domains.
Uniform attention. represents the no-focal-structure limit: attention is spread uniformly across tokens, testing whether the downstream feature is overly dependent on a concentrated learned attention pattern.
Random attention. represents unstructured corruption: attention weights are replaced with a random row-normalized distribution, testing robustness to noisy or unreliable attention allocation.
Reversed attention. represents complementary saliency: high-attention regions under the learned map are suppressed while lower-attention regions are emphasized, testing whether the representation over-relies on source-salient regions that may not transfer under domain shift.
Together, these perturbations cover three qualitatively different regimes: removing focal structure, injecting unstructured noise, and emphasizing regions complementary to the learned attention. We do not claim that they exhaust all possible attention corruptions or form an optimal perturbation basis. Instead, they provide a compact and label-free set of attention-space stress tests for regularizing attention-conditioned features.
9 Ablation study of the effectiveness of source model variants
Analysis of how different source model variants, trained with distinct attention modules impact the overall adaptation performance. For fair analysis we exclude the CAFC and DGASS modules from the adaptation framework. We train three variants of source model and adapt it on target domain by simply leveraging self-labeling and information maximization loss. Variants are created by utilizing different attention softmax against each variant, on office-home. Variant-1 is trained with standard softmax-based attention weights (), variant-2 is trained with a weighted softmax () and variant-3 is trained with learnable weighted average of variant-1 and variant-2 () as shown in main paper. As reported in Table 9, different variants shows its generalizable ability. We select the best two variant which is Variant-1 and Variant-3 in this case. Based on this study, we utilized these two variants across all datasets.
10 Statistical Significance and Seed-Level Robustness
To assess whether the improvements introduced by CAFC are robust to random-seed variation, we perform paired significance analysis using matched seed-level runs under the standard DomainBed-style ImageNet-pretrained ResNet-50 protocol. For each DG objective, the baseline model and its corresponding CAFC-augmented variant are evaluated using the same random seed. We conduct the analysis over four objectives for which complete matched seed-level results are available on both PACS and VLCS: CORAL, ERM, GroupDRO, and Mixup. This gives objectives seeds matched seed-objective observations per dataset.
For each matched observation , we define the accuracy difference as
Positive indicates an improvement from adding CAFC.
We report the mean paired improvement, its 95% confidence interval, a two-sided paired -test, and a one-sided Wilcoxon signed-rank test with the alternative hypothesis that CAFC improves accuracy. The paired -test measures whether the mean matched improvement differs from zero, while the Wilcoxon test provides a complementary non-parametric assessment that does not rely on normality of the paired differences.
Seed Objective Base +CAFC 0 CORAL 80.92 82.55 +1.63 0 ERM 78.47 80.68 +2.21 0 GroupDRO 82.21 81.81 -0.41 0 Mixup 84.93 85.50 +0.57 1 CORAL 81.78 82.48 +0.70 1 ERM 78.07 81.03 +2.96 1 GroupDRO 79.23 81.86 +2.62 1 Mixup 82.31 83.06 +0.76 2 CORAL 81.80 81.78 -0.02 2 ERM 80.82 82.70 +1.88 2 GroupDRO 82.86 85.17 +2.31 2 Mixup 83.66 85.07 +1.41
Table 10: Matched seed-level comparison on PACS under the standard DomainBed-style ImageNet-pretrained ResNet-50 protocol. Each Base and +CAFC value is the average accuracy across the four held-out PACS domains for the corresponding objective and random seed. denotes the paired gain from CAFC.
Seed Objective Base +CAFC 0 CORAL 77.66 79.35 +1.68 0 ERM 77.06 79.87 +2.81 0 GroupDRO 77.18 78.53 +1.35 0 Mixup 79.15 79.67 +0.52 1 CORAL 77.84 78.10 +0.26 1 ERM 77.06 80.82 +3.77 1 GroupDRO 77.59 79.42 +1.83 1 Mixup 78.85 80.28 +1.43 2 CORAL 77.66 79.19 +1.54 2 ERM 77.77 80.58 +2.81 2 GroupDRO 77.05 78.33 +1.28 2 Mixup 78.48 79.11 +0.64
Table 11: Matched seed-level comparison on VLCS under the standard DomainBed-style ImageNet-pretrained ResNet-50 protocol. Each Base and +CAFC value is the average accuracy across the four held-out VLCS domains for the corresponding objective and random seed.
Dataset Improved pairs Mean 95% CI Paired -test Wilcoxon PACS 10/12 +1.38 pp [0.71, 2.06] VLCS 12/12 +1.66 pp [1.00, 2.31]
Table 12: Summary of paired statistical significance tests. Tests use the 12 matched seed-objective observations per dataset. The paired -test is two-sided; the Wilcoxon signed-rank test uses the one-sided alternative that CAFC improves accuracy.
PACS.
As shown in Table 10, CAFC improves 10 of the 12 matched seed-objective observations. The mean paired gain is percentage points, with a 95% confidence interval of . A paired -test yields with , indicating that the mean improvement is significantly different from zero. The result is corroborated by the one-sided Wilcoxon signed-rank test (). Although two individual paired runs show negligible or modest negative changes, the aggregate effect across objectives and seeds remains consistently positive and statistically significant.
VLCS.
Table 11 shows an even stronger consistency pattern on VLCS: CAFC improves all 12 matched seed-objective observations. The mean paired improvement is percentage points, with a 95% confidence interval of . The paired -test gives and , while the one-sided Wilcoxon signed-rank test gives . Both tests therefore support a robust positive effect of CAFC across objectives and random seeds.

Figure 1: t-SNE visualization of the of OfficE-Home dataset. Left: Source-only. Right: DGA-CAFC (best view in color).
Discussion.
These paired seed-level results complement the meanstandard-deviation results reported in the main paper. In particular, the gains from CAFC are not driven by a single objective or an isolated random seed: CAFC improves 10/12 matched runs on PACS and 12/12 on VLCS, with statistically significant paired improvements on both benchmarks. This strengthens the evidence that the observed DG gains under the standard DomainBed protocol reflect a systematic effect of the CAFC regularizer rather than random seed variation.
11 Seed Variance Reduction
Beyond mean accuracy gains, CAFC reduces seed-to-seed variance for several DG objectives. Table 13 reports the standard deviation across three seeds, before and after adding CAFC, under the ResNet-18-from-scratch isolation setting (main paper, Tables 4–5).
Dataset Objective Std (Base) Std (+CAFC) PACS GroupDRO 1.85 1.06 PACS Mixup 5.52 2.46 VLCS GroupDRO 1.79 0.15 VLCS Mixup 0.89 0.36
Table 13: Seed-to-seed standard deviation, before and after CAFC, for the two objectives showing the largest variance reduction (ResNet-18 isolation setting). Lower values indicate more consistent performance across random seeds.
For both objectives on both datasets, CAFC substantially tightens the spread of results across seeds – most notably a 12 reduction for GroupDRO on VLCS (1.79 0.15). This indicates that CAFC’s benefit is not limited to the mean accuracy gains reported in the main paper, but also improves the reliability and predictability of training outcomes across random initializations.
12 t-SNE visualization
Figure 1 shows the t-SNE visualization of source (blue) and target features (red). Left one shows the learned features of source and target with the source-only model, right one shows the learned features through the proposed DGA-CAFC model for task.