A useful place to read a deep network is its middle layers, not its last one. Middle layers still know where things are, so they preserve object outlines, boundaries and layout. They are also abstract enough to ignore pixel noise. That is why they help when there are few labels. In medical imaging, adding self-supervised losses to the middle blocks of a ResNet-50 raised diabetic-retinopathy AUC from 88.1% to 93.6% with 1% of labels. Those same middle layers also mix two kinds of information. One is content: the anatomy and where it sits. The other is style: the scanner, contrast setting or staining that decides how the anatomy looks. Existing intermediate-layer pretraining forces the whole middle representation to stay unchanged under augmentation. Existing content–style methods for medical segmentation separate the two only at the encoder's last layer, where spatial detail is already lost.
We propose to split each intermediate feature map directly. The per-channel mean and variance of a feature map carry no spatial position, so they become the style code. The map normalized by those statistics becomes the content code. We pretrain by swapping the statistics between images from different scanners at one layer and requiring the content at deeper layers to stay identical pixel by pixel. A second objective requires the statistics to identify the scanner. The bet is that this gives a better starting point for segmentation with one to a handful of target labels than either forcing everything to be invariant or throwing the statistics away. We test it on the cross-modality MRI and cross-dataset polyp benchmarks where the strongest label-efficient disentangled method has published numbers.
Core Claim
Take a feature map $h_l \in \mathbb{R}^{H\times W\times C}$ at block $l$, with height $H$, width $W$ and $C$ channels. Let $\mu_l, \sigma_l \in \mathbb{R}^C$ be its per-channel spatial mean and standard deviation. We define the style code $s_l = (\mu_l,\sigma_l)$ and the content code $c_l = (h_l-\mu_l)/\sigma_l$.
The decomposition itself is borrowed. ALADIN builds a style descriptor from these per-layer statistics because they cannot carry spatial position. ALADIN discards the content half and is trained on 2.6M weakly labelled artworks. We keep both halves and make the content half the object of training.
The training intervention works as follows. We take an image $x$ and an image $x'$ from another domain, such as another scanner or MRI sequence. At a randomly chosen intermediate block $l$, we replace $x$'s statistics with those of $x'$:
$$\tilde h_l = \sigma'_l \odot c_l(x) + \mu'_l .$$
We then continue the forward pass. Here $\odot$ is channel-wise scaling and $\mu'_l,\sigma'_l$ are the statistics of $x'$.
The swap changes how the image looks but not its geometry, so pixel $p$ in the original pass and pixel $p$ in the swapped pass show the same anatomy. That means we can apply a dense contrastive loss to the content codes at every deeper block $k>l$ without hand-crafted correspondence:
$$\mathcal{L}_{\text{content}} = -\sum_{k>l}\sum_{p}\log\frac{\exp(\langle c_k(x)_p, \tilde c_k(x)_p\rangle/\tau)}{\sum_{q}\exp(\langle c_k(x)_p, \tilde c_k(x)_q\rangle/\tau)}.$$
In this loss, $\tilde c_k$ is the content after the swap, $p,q$ index spatial locations and $\tau$ is a temperature. A style loss on the concatenated multi-layer statistics pulls together images from the same domain and pushes apart different domains. Domain identity comes free with domain-adaptation data, and this loss gives the style stream a job instead of letting it absorb leftovers.
This follows the view in Self-Supervised Learning with Data Augmentations Provably Isolates Content from Style, which proves that contrastive learning isolates content when augmentations act as interventions on style. That proof is stated for final-layer latents and idealized augmentations. The statistic swap is a much narrower intervention than an image-level augmentation, and it is applied at the depth where content is still spatial.
The claim is falsifiable in a specific way. The split should help most when target labels are scarcest and the domain gap is largest. It should beat two alternatives. The first is monolithic intermediate invariance, which also forces the statistics to be invariant even when intensity carries diagnostic signal, such as tumour contrast on MRI. The second is plain instance normalization, which deletes the statistics.
Relation to the Closest Work
Two papers define the space, and the proposal differs from each in one specific respect.
Intermediate Layers Matter in Momentum Contrastive Self Supervised Learning adds mean-squared-error or Barlow Twins losses to every ResNet-50 residual block for positive pairs. Its evidence that middle layers matter under 1% labels motivates this proposal. However, it treats each block's output as a single block of channels to be made invariant, and it evaluates only classification. We split each block's output and evaluate dense segmentation under domain shift.
Semi-supervised Domain Adaptive Medical Image Segmentation through Consistency Regularized Disentangled Contrastive Learning has separate content and style contrastive heads and a student–teacher fine-tuning stage. It reaches 72.2% Dice with one labelled target MRI. Its heads sit on the final encoder output, so it adds a dense propagation module to recover spatial detail. Its style views come from swapping low-frequency Fourier amplitudes, which assumes style lives only at low frequencies. We move the split into the middle layers, where spatial detail already exists. We replace the Fourier swap with statistic swaps at several depths. Deeper-layer statistics capture texture-like appearance as well as global intensity. We reuse its student–teacher fine-tuning unchanged so that the pretraining is the only difference.
Two further papers constrain the design. Image Disentanglement and Uncooperative Re-Entanglement for High-Fidelity Image-to-Image Translation shows that high-dimensional style codes hide structural coordinates. With cooperative training, factor correlation was 0.695, against 0.998 with uncooperative training. This is why we keep style strictly as spatially pooled statistics rather than a dense map. It also means we must check that content is not leaking style in the other direction.
Learning Saliency-Free Model with Generic Features for Weakly-Supervised Semantic Segmentation shows that ResNet-101 block C41 captures whole object extents. It reaches 64.5% validation mIoU on VOC 2012 from image labels alone. We treat this as evidence that block 3 is the natural place to enforce content structure, but we test layer choice rather than assume it.
Research Program
Pretraining uses a ResNet-50 encoder with a U-Net-style decoder. The same architecture is used for every method so that only the pretraining objective differs. The unlabelled pool is all source and target images. For each pair, the swap layer is sampled from blocks 2 and 3. Content losses are applied at all deeper blocks, and the style loss is applied to the concatenated statistics of all blocks.
At fine-tuning, the decoder receives content maps through the skip connections and re-injects the style statistics by affine modulation. Intensity information therefore stays available but enters through a separate, controlled channel. Fine-tuning then follows the student–teacher procedure of Basak et al. on the labelled target images plus unlabelled target data.
Three analyses accompany the main results. The first is a leakage audit. We train linear probes to predict domain from pooled content codes and to predict a coarse segmentation from the style vector. Success means near-chance accuracy in both directions, compared against the same probes on the monolithic baseline. The second is a layer sweep over which block receives the swap and which blocks receive the content loss. This turns the layer-selection heuristic noted as open in LayerSync into a measured curve for this task. The third is a stress test on shifts that first and second moments cannot express, such as additive structured noise. This tells us where the method stops working.
Baselines
The naive reference is the same encoder–decoder initialised from ImageNet and fine-tuned with the student–teacher procedure on the same labelled target images, with no domain-specific pretraining. It shows how much any pretraining buys.
The final-layer self-supervised baseline is standard MoCo pretraining on the same unlabelled pool, followed by identical fine-tuning.
The intermediate-invariance baseline is MoCo plus per-block mean-squared-error and, separately, Barlow Twins losses, as in Intermediate Layers Matter. It is the strongest competitor on the "do middle layers help" axis. That paper reports 93.6% AUC with 1% EyePACS labels, against 88.1% for MoCo. It has no segmentation result, so for segmentation we reproduce it ourselves.
The strongest existing method on our exact benchmarks is Basak et al.. It reports 72.2% Dice for T2→T1 brain-tumour MRI with one labelled target, where the prior best was 69.7%. It also reports 87.7% Dice for CVC-EndoScene→Kvasir-SEG with 10% labels. We cite these numbers and also rerun the method in our codebase with our encoder, so that differences in implementation do not decide the comparison.
All methods get the same unlabelled data, pretraining epochs and fine-tuning schedule. Each gets an equal hyperparameter grid of the same size, tuned on a held-out target validation split. One-label results vary hugely with which image is labelled. We therefore report mean and spread over at least five different labelled-image draws and three seeds, using the same draws for every method.
Beating the strongest baseline means two things. First, mean Dice above both the published 72.2% and our reproduction on MRI with one label. Second, a paired improvement over the reproduction across draws that exceeds its spread. On polyps, the same test applies against 87.7% at 10% labels. Gains of under a point within noise count as a tie, and a tie would undercut the claim.
The ablations isolate the key ingredient. The first applies instance normalization to intermediate maps with a monolithic intermediate loss and no style stream. The second uses the statistic swap only as an augmentation for MoCo, with no dense content loss. The third keeps the content loss but drops the style loss. The fourth drops style re-injection in the decoder.
Why not just…?
Why not just add the existing intermediate-layer losses and fine-tune a segmenter? This is the most direct competitor, and it may already capture most of the gain. Its loss compares pooled or whole-map features of two augmented views. It never asks that the same pixel carry the same content under an appearance change, and it forces the feature statistics to be invariant along with everything else. Our expectation is that this costs accuracy specifically on MRI, where the statistics carry lesion contrast. The ablation ladder settles it: monolithic → statistic-swap augmentation only → full split. If the monolithic baseline matches the full method within noise, the split is not earning its complexity, and we would report that.
Why not just instance-normalize the middle layers and skip the style stream? This is a real threat, because if style were exactly the channel statistics, normalization alone would remove it for free. Two things argue against it, and the experiment tests both. First, deleted statistics cannot be recovered when intensity is diagnostic, whereas our decoder re-injects them. Second, normalization at the swap layer does not stop deeper layers from rebuilding scanner cues, while our deeper-block content loss does. The leakage audit shows whether domain is still decodable from normalized-only features. The no-style ablation shows what the style loss adds. If plain normalization ties, the honest conclusion is that the contribution is a simpler recipe, and we would present it that way.
Why not just use Basak et al. as is, since its U-Net skips already pass intermediate features to the decoder? Skip connections pass intermediate features through, but nothing in that method's pretraining shapes them. Its content and style objectives touch only the final layer, and its added dense propagation module exists to make up for the last layer's lost detail. The fair test is to rerun it in our codebase with an identical encoder–decoder and identical fine-tuning, so the only difference is where and how the split is enforced.
Why not just use stronger image-level augmentation, such as Fourier low-frequency swaps or colour jitter? Self-Supervised Learning with Data Augmentations Provably Isolates Content from Style calls image-level augmentations blunt instruments that can damage content. Magnification Prior reports that generic augmentations can destroy diagnostic tissue structure. The Fourier swap also assumes low-frequency style. We compare directly by giving the Fourier swap to the monolithic baseline and to our method. The noise stress test shows whether either one handles shifts the other misses.
Proposed Experiments
The primary experiment is T2→T1 brain-tumour MRI adaptation with 1, 3 and 5 labelled target images, measured by Dice. The second is CVC-EndoScene→Kvasir-SEG polyp segmentation with 1%, 5% and 10% target labels, also measured by Dice. Both are taken from Basak et al. so that published numbers anchor the comparison.
As a secondary check, we test whether the split preserves the classification gains of intermediate supervision. We linear-probe and fine-tune the pretrained encoder on EyePACS with 1% labels and compare against the reported 93.6% AUC. We only reproduce that baseline under our settings if our pretraining data differ. No reported result was found on Lacuna for per-dataset NIH Chest X-ray numbers under that method, so we do not use NIH as an anchor.
The decisive pattern has three parts. First, a paired improvement over the reproduced Basak baseline at one label that shrinks as labels grow. Second, the full split clearly beating both the instance-normalization ablation and the swap-as-augmentation ablation. Third, the leakage audit showing lower domain decodability from content than the monolithic baseline at matched segmentation accuracy.
If the gain does not shrink as labels grow, or if instance normalization ties, the claim as stated fails. The work would then reduce to the more modest finding about where normalization should go.
References
- ALADIN: All Layer Adaptive Instance Normalization for Fine-grained Style Similarity
- Self-Supervised Learning with Data Augmentations Provably Isolates Content from Style
- Intermediate Layers Matter in Momentum Contrastive Self Supervised Learning
- Semi-supervised Domain Adaptive Medical Image Segmentation Through Consistency Regularized Disentangled Contrastive Learning
- Image Disentanglement and Uncooperative Re-Entanglement for High-Fidelity Image-to-Image Translation
- Learning Saliency-Free Model with Generic Features for Weakly-Supervised Semantic Segmentation
- LayerSync: Self-aligning Intermediate Layers
- Magnification Prior: A Self-Supervised Method for Learning Representations on Breast Cancer Histopathological Images