Supervised Contrastive Block Disentanglement

Taro Makino, Ji Won Park, Natasa Tagasovska, Takamasa Kudo, Paula Coelho, Heming Yao, Jan-Christian Huetter, Ana Carolina Leote, Burkhard Hoeckendorf, Stephen Ra, David Richmond, Kyunghyun Cho, Aviv Regev, Romain Lopez · Submission to ICLR 2025 · Rejected

TL;DR

Combining experimental datasets across multiple hospitals or lab batches often introduces spurious technical artifacts that models latch onto. The authors introduce Supervised Contrastive Block Disentanglement (SCBD), a non-adversarial, contrastive learning method that cleanly splits representations into target-relevant features ($z_c$) and environment-specific artifacts ($z_s$). Evaluated on a massive dataset of 26 million single-cell images, SCBD effectively removes batch effects and outperforms human-engineered baselines like CellProfiler.

What Problem Does This Paper Address?

In applications like computational pathology and high-throughput biology, datasets are often compiled from diverse sources—such as different hospitals, instruments, or experimental batches (wells). While pooling data increases sample size, it also introduces spurious correlations or batch effects (e.g., variation in slide staining or microscope brightness). Standard machine learning models frequently exploit these domain-specific shortcuts, causing them to fail when deployed to new environments.

Existing strategies for separating signal from domain bias typically rely on:

  1. Adversarial training (e.g., Domain-Adversarial Neural Networks), which requires unstable minimax optimization.
  2. Variational Autoencoders (VAEs), which are difficult to scale to high-dimensional images due to posterior/prior collapse and gradient instabilities.

The authors set out to achieve block disentanglement—learning a target-predictive representation $z_c$ invariant to environment $e$, and a nuisance representation $z_s$ capturing $e$—using a stable, purely contrastive framework.

Methods

SCBD extends Supervised Contrastive Learning (SCL) into a multi-head representation framework without adversarial discriminators or variational approximations:

  • Dual Encoders & Projections: Two encoders map an input image $x$ to separate embeddings:
  • $z_c$: Encodes the target phenomenon $y$ (e.g., disease state or genetic perturbation).
  • $z_s$: Encodes the experimental condition $e$ (e.g., hospital ID or plate well).
  • Objective Function: $$\min \mathcal{L}_{\text{sup}}(z_c, y) + \mathcal{L}_{\text{sup}}(z_s, e) + \alpha \mathcal{L}_{\text{inv}}(z_c, e) - \log p(x \mid \text{Dec}(z_c, z_s))$$
  • $\mathcal{L}_{\text{sup}}(z_c, y)$: Pulls representations of the same label $y$ together on the unit hypersphere.
  • $\mathcal{L}_{\text{sup}}(z_s, e)$: Clusters representations sharing the same batch/environment $e$.
  • Novel Contrastive Invariance Loss ($\mathcal{L}_{\text{inv}}$): Forces $z_c$ to be equally likely to match positive and negative pairs across different environments $e$. By penalizing environment separability in $z_c$ directly via dot-product matching probabilities, it purges $e$-dependent information without training a separate discriminator.
  • Reconstruction Loss: An optional additive decoder reconstructs $x$ from $z_c + z_s$. To preserve training stability, the decoder is trained while keeping the encoder representations fixed.

Datasets

The authors evaluate SCBD on synthetic, biological, and clinical datasets:

  1. Colored MNIST (CMNIST): Digits 0–9 where color is heavily correlated with digit class in two training environments ($e \in \{0, 1\}$), but all digits are white in the test set.
  2. Optical Pooled Screens (OPS): A massive real-world biological dataset of 26 million single-cell images across 34 wells, measuring the morphological effects of 5,050 genetic perturbations.
  3. Camelyon17-WILDS: Breast tissue histopathology patches collected across five hospitals, evaluating tumor detection under severe inter-hospital staining shifts.
  4. PACS & VLCS: Standard domain generalization benchmarks from DomainBed (used in ablation/negative result analyses).

Key Insights and Ideas

  • Disentanglement without Minimax: By reframing domain invariance as flattening the supervised contrastive matching probability across environments, SCBD avoids the instability of adversarial training and the optimization traps of VAEs (such as posterior collapse).
  • A Single Tunable Knob ($\alpha$): The hyperparameter $\alpha$ provides monotonic control over the trade-off: higher $\alpha$ increases environment invariance in $z_c$, directly improving out-of-distribution (OOD) performance.
  • The "ID vs. OOD" Requirement: SCBD specifically targets datasets where in-distribution shortcut learning hurts OOD generalization (e.g., CMNIST and Camelyon17). When in-distribution and OOD accuracy are positively correlated (as observed in PACS and VLCS), forcing invariance offers no benefit—a crucial reality check for domain generalization research.

Key Results

  • Optical Pooled Screen Batch Correction:
  • Biological relevance (CORUM protein complex prediction): SCBD achieved the highest Area Under the Precision-Recall Curve ($\text{AUPRC} \approx 0.024$), outperforming human-engineered CellProfiler features ($\approx 0.021$), identifiable VAEs ($\approx 0.021$), and multi-contrastive VAEs ($\approx 0.019$).
  • Batch effect removal (Well prediction): When predicting the batch/well from embeddings using logistic regression, SCBD reduced the classification F1 score to nearly 0.0, compared to $\sim 0.05$ for CellProfiler and $>0.40$ for vanilla VAEs.
  • Domain Generalization:
  • CMNIST: SCBD ($\alpha=192$) reached 82.9% test accuracy, dramatically outperforming ERM (37.8%) and iVAE (52.1%).
  • Camelyon17-WILDS: SCBD achieved 72.7% accuracy, surpassing ERM (65.8%), IRM (66.3%), and Group DRO (68.4%).

Limitations and Future Work

  • Supervision of Nuisance Variables: SCBD requires explicit labels for the environment/batch variable $e$. Future work is needed to discover and disentangle hidden confounders unsupervised from raw data.
  • Non-Joint Generative Modeling: Because the decoder is trained post-hoc on frozen embeddings to preserve stability, reconstructed images are blurry. Jointly optimizing the generative decoder and contrastive encoders without losing representations remains open.
  • Hyperparameter Selection: Finding the optimal $\alpha$ under an unknown test distribution remains a classic challenge in domain generalization, as validation performance decreases when $\alpha$ increases.

Summary updated

BibTeX
@misc{makino2025supervised,
  author = {Taro Makino and Ji Won Park and Natasa Tagasovska and TAKAMASA KUDO and Paula Coelho and Heming Yao and Jan-Christian Huetter and Ana Carolina Leote and Burkhard Hoeckendorf and Stephen Ra and David Richmond and Kyunghyun Cho and Aviv Regev and Romain Lopez},
  title = {{Supervised Contrastive Block Disentanglement}},
  year = {2025},
  eprint = {2502.07281},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.07281},
}
Figure