Routing Conflicting Pseudo-Label Gradients Away From Content Features in Semi-Supervised Domain Generalization

Semi-supervised domain generalization trains a classifier on a few labeled images from several source domains (say, photos, sketches and cartoons), plus many unlabeled images. The goal is a model that works on a domain it has never seen. The standard recipe gives unlabeled images "pseudo-labels", the model's own confident guesses, and trains on them. Under domain shift, many of those guesses are wrong. Training on wrong guesses can teach the shared features to track domain appearance rather than object identity, and the network then stops being invariant to the shift. We propose to treat each unlabeled training signal as a small task whose gradient either agrees or conflicts with the gradient from the trusted labeled data. Two mechanisms follow. Pseudo-label gradients that conflict with the labeled gradient are blocked from the "content" channels the classifier relies on. Gradients from a domain-prediction head are confined to a separate set of "style" channels.

The intended outcome is a content/style split of the backbone that comes from routing gradients, not from reconstruction decoders or extra copies of per-domain parameters. We also want a test of a specific hypothesis. Existing methods filter pseudo-labels by confidence. We hypothesize that disagreement with the labeled gradient detects harmful pseudo-labels better than confidence does, and that the advantage is largest on images whose style is far from the labeled data.

Core Claim

Our hypothesis is that in this setting, damaging confirmation bias concentrates in unlabeled examples whose loss gradient points against the labeled-data gradient. Confidence alone does not separate these examples well, because a network can be confidently wrong when it latches onto domain style. If that holds, a simple rule should beat confidence-only pseudo-labeling and should not need parameters that grow with the number of domains. The rule lets each unlabeled example update the content channels only when its gradient agrees with the labeled gradient. When it conflicts, its update goes to the style channels only.

The claim is falsifiable at two levels. The first is diagnostic: on standard benchmarks the true labels of the "unlabeled" pool are known. We can therefore measure whether gradient conflict predicts pseudo-label error better than confidence, measured by area under the ROC curve (AUROC). The second is end to end: target-domain accuracy against the strongest existing method.

Relation to Prior Work

Three lines of semi-supervised domain generalization work motivate the gap. Semi-Supervised Domain Generalization with Stochastic StyleMatch extends FixMatch, a confidence-thresholded pseudo-labeling method. It adds stochastic class prototypes and a third view restyled with adaptive instance normalization (a way of swapping one image's color/texture statistics onto another), so predictions are pushed to ignore style. Its pseudo-label selection is still confidence-based. MultiMatch diagnoses cross-domain interference in batch normalization. It gives each source domain its own normalization layers and classifier head, and keeps a pseudo-label only when the local and global heads agree. Its cost grows linearly with the number of domains, and it treats interference as a statistics problem rather than an optimization problem. DIVA and DGNet separate class, domain and residual (or anatomy and appearance) factors using variational or reconstruction objectives. The research file notes that balancing reconstruction, KL, domain and task losses becomes fragile as the unlabeled-to-labeled ratio grows.

Our method borrows its mechanics from gradient isolation. Split to Learn: Gradient Split for Multi-Task Human Image Analysis partitions convolutional filters into task groups and lets each group receive gradients only from its own task and non-conflicting tasks, while all filters are used in the forward pass. We reuse the forward-shared, backward-partitioned design. Boosting Multimodal Learning via Disentangled Gradient Learning detaches the fused loss from modality encoders and replaces it with cleaner per-branch losses. This shows that cutting a harmful gradient path can beat joint training.

Two differences set our proposal apart. In GradSplit the tasks and their conflict relations are fixed in advance. In our method the "tasks" are unlabeled examples, and the routing decision is recomputed every step from measured gradient agreement. And unlike DGL, which needs per-branch auxiliary losses to drive the isolated branches, our style channels are driven by a domain label that is free in this setting.

The gradient-interference literature motivates measuring conflict with inner products between gradients. The research file contains no reported result for gradient-surgery methods applied to semi-supervised domain generalization. We therefore treat that combination as untested rather than as known to fail or succeed. The file also lacked a section listing direct prior attempts at this exact combination. The closest work we found is the GradSplit, MultiMatch and DGNet trio.

Research Program

The backbone, ResNet-18 as in the cited benchmarks, keeps its forward pass unchanged. In each of the last two residual stages, channels are split into a content group and a style group, starting with 75% content. The classifier reads globally pooled content channels only. A small domain-classification head reads style channels only. A stop-gradient on its input keeps domain-label gradients out of the content group.

The conflict measurement is cheap. For a softmax classifier with weights $W$, one example's cross-entropy gradient with respect to $W$ is the outer product $(p - y)\,h^\top$. Here $p$ is the predicted distribution, $y$ the one-hot (pseudo-)label, and $h$ the pooled content feature. The inner product between two such gradients therefore has a closed form and costs essentially nothing per example. For each unlabeled example $u$ we compute

$$c_u = \cos\big(g_u,\ \bar g_L\big),$$

where $g_u$ is $u$'s pseudo-label gradient on $W$ and $\bar g_L$ is the mean labeled-batch gradient on $W$, kept as an exponential moving average to reduce noise from few labels. The routing rule is then

$$\mathcal{L}_u^{\text{content}} = \mathbb{1}[c_u > \tau]\,\ell_u,$$

where $\ell_u$ is the usual pseudo-label loss and $\tau$ is a threshold, default zero. Examples with $c_u \le \tau$ still update the style channels, so their information is absorbed rather than discarded. We will also report a soft variant that weights each example by $\max(c_u, 0)$.

To check that the cheap last-layer proxy is faithful, we will measure true per-domain gradient cosines on the last residual stage's parameters every few hundred steps. We will report how often the proxy and the full check agree.

The program has three parts. The first is diagnostic and needs no new method. In plain FixMatch training, we test whether $c_u$ separates correct from incorrect pseudo-labels better than confidence does, overall and binned by the style distance of each image from the labeled set. The second builds and tunes the routed model. The third analyzes what each channel group learned. A linear probe predicts domain from content features and from style features, and a probe predicts class from style features. We also run a test-time swap: style channels are exchanged between images and we measure whether the class prediction stays put.

Baselines

The naive reference point is FixMatch run on all source domains with a shared backbone. In the MultiMatch paper it reaches 77.83% on PACS and 57.86% on Office-Home with 10 labels per class. Any method that does not clear this margin clearly is not worth its complexity.

StyleMatch is the strongest competitor that addresses style directly. It reports 80.32% on PACS and 56.72% on Office-Home with 5 labels per class, and MultiMatch reports it at 80.41% on PACS with 10 labels. We include it because its style-consistency view is the most direct alternative way to make content features ignore style.

MultiMatch is the strongest existing method on our question. It reports 81.57% on PACS and 62.57% on Office-Home with 10 labels per class, and 58.79% on miniDomainNet versus 55.13% for StyleMatch. Its local/global agreement filter is the closest existing answer to "which pseudo-labels should be trusted". Beating it means exceeding its reported numbers under its own protocol: leave-one-domain-out, same label budgets, same backbone, mean over three seeds. We also require exceeding our own rerun of it with matched tuning effort, using the same number of hyperparameter trials for each method, chosen by source-domain validation only. A gain of about one point on PACS and Office-Home, reproduced across seeds, would count, especially if we match MultiMatch with fewer parameters. If we only tie it, we will say so and fall back on the parameter-count and diagnostic contributions.

Three ablations isolate the key ingredient. The first keeps the content/style split and the domain head but routes by confidence instead of $c_u$, which separates routing from architecture. The second uses gradient-conflict filtering without any channel split: conflicting examples are simply dropped. This tests whether the style group earns its place. The third gives the domain head full gradient access to the content channels, which shows whether isolation matters.

Why not just…?

Why not just raise the confidence threshold or use MultiMatch's agreement filter? This is the most serious threat, since agreement filtering already removes many wrong pseudo-labels; MultiMatch reports 90.51% pseudo-label accuracy for StyleMatch-style training. The diagnostic experiment settles it directly. If confidence and $c_u$ have equal AUROC for detecting wrong pseudo-labels, especially on far-from-labeled styles, the core hypothesis fails and we would report that rather than push the method. We will also test the combination, since the signals could be complementary.

Why not just apply gradient surgery across domains, projecting away conflicting components, without any content/style split? This is plausible, and the research file has no reported result for it in this setting. We include it as a direct baseline, with projection applied between per-domain pseudo-label losses. Our argument for the split is that projection discards the conflicting signal entirely, while routing keeps it in style channels, which could later help the domain head and calibration. If projection matches our method, the split is unjustified and we will say that.

Why not just use style augmentation, as StyleMatch does, and skip gradient routing? Augmentation teaches invariance only to the style changes the augmenter can produce, here channel-statistic swaps. It does nothing about wrong pseudo-labels whose errors come from shape-level domain cues, such as sketch strokes. The style-swap probe and the per-domain breakdown on sketch and clipart domains will show whether routing helps where augmentation cannot. We will also run the two together, since they are not exclusive.

Why not just learn disentangled factors with a variational model like DIVA or DGNet? Those methods need reconstruction decoders and several loss weights. The research file flags their balancing as fragile when unlabeled data dominates, and their published results are on Rotated MNIST, malaria cells and cardiac MRI rather than PACS-scale photos. We do not rerun them on all benchmarks. We compare on parameter count and tuning burden, and on DGNet's M&Ms protocol if time allows. There DGNet reports 72.85% Dice with 2% labels.

Proposed Experiments

The main benchmarks are PACS and Office-Home at 5 and 10 labels per class per domain, and miniDomainNet. Each uses leave-one-domain-out evaluation, the backbone and label budgets of the cited papers, and three seeds. Metrics are target-domain accuracy, parameter count relative to MultiMatch, and wall-clock overhead of the conflict computation.

The first decisive check is the AUROC comparison of $c_u$ versus confidence for flagging wrong pseudo-labels, using held-back ground truth. It is reported per source domain and per style-distance bin. The method only makes sense if this comparison favors $c_u$.

The second is the end-to-end comparison against MultiMatch's reported 81.57% on PACS and 62.57% on Office-Home at 10 labels, with the matched-budget rerun alongside.

The third tests whether the channel groups actually separated. Domain must be predictable from style channels and much less predictable from content channels than in FixMatch features, and swapping style channels must leave class predictions largely unchanged.

A scaling stress test on miniDomainNet, varying the number of source domains, checks the claim that our parameter count stays constant while MultiMatch's grows. Finally, we check that the routing threshold $\tau$ is not a hidden source of tuning advantage. Accuracy should be stable for $\tau$ in a small range around zero; if it is not, we will report how much the result depends on $\tau$.