Adding a decoder that must rebuild the input from a network's internal features is a cheap, widely used way to stop the network from throwing away useful information. When the goal is to work on a new hospital, scanner, or image style never seen in training, this trick runs into a contradiction. Faithful reconstruction requires the features to remember everything, including the scanner noise and artistic style that make a site distinctive. One line of work therefore minimizes reconstruction error to prevent collapse, while another trains the encoder to maximize it so that style is purged. We propose a simple way out. Hand the decoder the nuisance for free, as the identity of the dataset or site plus a few cheap per-image style statistics. Once the decoder already knows "this is a sketch" or "this is site 7's scanner," the encoder gains nothing by storing that style. The reconstruction loss then pressures the features to keep only the content the decoder cannot get elsewhere.
The claim is testable with standard cross-dataset protocols such as leave-one-domain-out and leave-one-site-out. It has a clear failure mode we can look for. If nuisance-conditioning only adds decoder capacity, a decoder fed shuffled site labels should do just as well. If it works for the reason we claim, it should beat both the minimize and maximize variants of reconstruction on held-out domains. It should also make the reconstruction weight easier to choose without seeing target data, which is the practical problem that keeps reconstruction regularizers out of real cross-site pipelines.
Core Claim
Let $E$ be the encoder producing features $z = E(x)$ from input $x$, $f$ the task head, and $D$ the auxiliary decoder. Let $d$ be the training-domain label, and let $s(x)$ be a fixed, non-learned summary of per-image style, such as channel-wise means and variances of the input. We train
$$ \mathcal{L} = \mathcal{L}_{\text{task}}(f(z), y) + \alpha\, \mathcal{L}_{\text{align}}(z) + \beta\, \lVert x - D(z, e_d, s(x)) \rVert^2 , $$
where $y$ is the label, $\mathcal{L}_{\text{align}}$ is any existing invariance penalty (IRM, MMD, CORAL), $e_d$ is a learned embedding of domain $d$ injected into the decoder by feature-wise scaling, and $\alpha, \beta$ are weights. The decoder is discarded at test time, so an unseen domain never needs an embedding.
The intuition can be stated information-theoretically. Reconstruction lower-bounds the information $z$ carries about $x$ given whatever the decoder already receives. Conditioning on $(e_d, s(x))$ turns the requirement "remember $x$" into "remember what is not explained by the domain and the global style." The second requirement is the one an alignment objective wants satisfied. It differs from the existing positions as follows. Trade-off between reconstruction loss and feature alignment for domain generalization proves that alignment without reconstruction discards task information, and adds an unconditioned decoder to IRM, MMD, CORAL and related methods. Its decoder must recover style from $z$, so it keeps style in $z$. Adversarial Reconstruction Loss for Domain Generalization makes the encoder maximize reconstruction error, which removes style but also any fine structure the decoder could use. We keep the minimizing direction that the first paper justifies theoretically, but change what must be reconstructed from $z$. The research file states this as the unreconciled tension: neither work separates reconstructible content from nuisance.
Research Program
The work has three parts. First, we build the conditioned decoder as a drop-in module for the Rec variants of IRM, MMD and CORAL. The comparison to Trade-off between reconstruction loss and feature alignment for domain generalization then changes exactly one thing: what the decoder is conditioned on. The style summary $s(x)$ is deliberately crude and non-learned. A learned style code would let the encoder route class information through a side channel. A fixed low-dimensional statistic cannot, and it still covers per-image nuisances like color casts that a domain label misses.
Second, we measure where information goes. We fit linear probes on frozen $z$ for domain identity, class, and site, and we compare reconstruction error with and without conditioning. The mechanism predicts three things. Domain-probe accuracy on $z$ should drop relative to unconditioned Rec. Class-probe accuracy should stay at or above Rec. Reconstruction quality should stay comparable, because the decoder gets style from the conditioning.
Third, we study model selection, the open problem that the cross-dataset literature flags most clearly. In target-blind settings, the reconstruction weight chosen on in-distribution validation often fails to transfer (Trade-off between reconstruction loss and feature alignment for domain generalization). We sweep $\beta$ and compute the rank correlation between training-domain validation accuracy and held-out-domain accuracy. Conditioning should raise this correlation, because larger $\beta$ no longer pulls nuisance into $z$. A weight that helps in-distribution should therefore stop hurting out-of-distribution. If this holds, it matters more in practice than any single accuracy gain.
Baselines
The naive reference is plain empirical risk minimization with weight decay and standard augmentation on the same backbone. Every method must at least match it on held-out domains to count. The direct parent is unconditioned Rec, meaning IRM-Rec, MMD-Rec and CORAL-Rec, as in Trade-off between reconstruction loss and feature alignment for domain generalization. It is the closest competitor because it already turns reconstruction into the right kind of help for alignment. Its reported number is the anchor: on CS-CMNIST, IRM goes from 61.5% to 71.0% accuracy with reconstruction. To beat it, our IRM variant must exceed IRM-Rec on CS-CMNIST under the same protocol. On the real-image benchmarks, where that paper reports nothing, it must exceed IRM-Rec across held-out domains with non-overlapping confidence intervals over seeds.
The opposite pole is adversarial reconstruction (Adversarial Reconstruction Loss for Domain Generalization). It reports a 0.70% average accuracy gain over prior methods across RMNIST, VLCS and IXMAS, at roughly 8 hours of training on VLCS against a 4-hour baseline. We found no per-dataset PACS number for it in the file. We re-run it rather than copy numbers. A structured but reconstruction-free competitor is Compositional Feature Alignment (Enhancing Compositional Generalization via Compositional Feature Alignment), which separates class and domain through orthogonal linear heads on CLIP or DINOv2. No per-dataset top-1 number for CFA on CG-Bench is reported in the file, so we run it with its released settings on our splits. On the neuroimaging track, the reference is SI-IGCL (SI-IGCL: Subject Invariance-aware Inverse Graph Contrastive Learning for Psychiatric Disorder Identification). It reports 75.27% accuracy on ABIDE and 74.26% on ADHD-200, but the file gives no per-site leave-one-site-out breakdown. We therefore compare per held-out site after re-running it.
Fairness rules apply to every method. All methods share one backbone per track and one decoder architecture where a decoder exists. Each gets an identical budget of random hyperparameter trials, about twenty per method, and the same seeds. We report two selection rules: training-domain validation and leave-one-training-domain-out validation. No method sees target labels during selection.
Two ablations isolate the key ingredient. In the first, the decoder receives a domain embedding with permuted domain assignments, and the same per-sample statistics taken from a random other image. This keeps decoder capacity and parameter count identical while destroying the information. In the second, we condition on only $e_d$ and then on only $s(x)$, to separate shared-domain style from per-image style. If the shuffled-conditioning ablation matches the full method, the claim is wrong.
Why not just…?
Why not just tune the reconstruction weight of plain Rec more carefully? This is the most serious threat. If unconditioned Rec with a well-chosen $\beta$ matches us, conditioning adds nothing. We settle this by giving Rec the same trial budget and the stronger leave-one-domain-out selection rule. We report the full $\beta$ sweep, not only the selected point. The proposal wins only if the conditioned curve sits above the unconditioned one over a range of $\beta$, or if its in-distribution-to-out-of-distribution rank correlation is clearly higher.
Why not just use adversarial reconstruction, which already removes style? Maximizing reconstruction error cannot tell style from content, and the file's own summary flags the risk of purging fine structure. Its reported average gain is small (0.70%). Our class-probe and fine-grained results, on DomainNet classes and per-site ABIDE, would show whether it loses class information that conditioned reconstruction keeps. If adversarial reconstruction matches us on fine-grained held-out domains as well, we will report that.
Why not just learn a separate style code and reconstruct from content plus style? A learned style branch is the standard disentangling autoencoder. Nothing stops the encoder from hiding class or shortcut information in that branch, and nothing stops the decoder from ignoring it. We include it as a baseline with matched capacity. The fixed statistic $s(x)$ is our answer to this leak. The comparison shows whether the restriction matters.
Why not just rely on alignment or heavy augmentation? The Rec analysis shows alignment alone discards task information. When and How Does CLIP Enable Domain and Compositional Generalization? shows that more diverse data does not prevent shortcut "private circuits" when a domain is only partly observed: Sketch accuracy moved from 19.5% to 36.9% depending only on class overlap. We still run MMD, CORAL and ERM with strong augmentation as baselines, so this is tested rather than assumed.
Proposed Experiments
The first experiment is a reproduction-and-prediction check on CS-CMNIST and CMNIST using the Rec code path. Our honest prediction is a small gain here. The nuisance, color, varies per sample and correlates with label within an environment. The domain label cannot absorb it, and only $s(x)$ can. If we see a large gain on CS-CMNIST but none on real benchmarks, the mechanism is not what we claim.
The main tests run leave-one-domain-out on PACS and VLCS, the benchmarks shared with adversarial reconstruction. They also use the OfficeHome and DomainNet compositional splits from CG-Bench, built with the understanding-clip-ood code. There, domain style is shared within a domain and should be absorbed by $e_d$.
The clinical test is leave-one-site-out on ABIDE and ADHD-200 connectivity graphs. There we replace SI-IGCL's unconditioned graph decoder with a site-conditioned one, keeping its inverse contrastive objective unchanged. The question is whether removing scanner "fingerprints" from what must be reconstructed improves the worst held-out site, not only the average. The metrics are held-out-domain accuracy (mean and worst domain or site), domain-probe and class-probe accuracy on $z$, reconstruction error, the in-distribution-to-out-of-distribution rank correlation across the $\beta$ sweep, and training wall-clock time relative to ERM.
The decisive checks are three. The full method must beat shuffled-conditioning at equal capacity. It must beat best-tuned unconditioned Rec on at least the real-image and site-held-out benchmarks. And domain-probe accuracy on $z$ must fall while class-probe accuracy holds. If any of these fails, the explanation offered here is wrong, whatever the headline accuracy.
References
- Trade-off between reconstruction loss and feature alignment for domain generalization
- Adversarial Reconstruction Loss for Domain Generalization
- Enhancing Compositional Generalization via Compositional Feature Alignment
- SI-IGCL: Subject Invariance-aware Inverse Graph Contrastive Learning for Psychiatric Disorder Identification
- When and How Does CLIP Enable Domain and Compositional Generalization?