A Contrastive Objective for Learning Disentangled Representations

Jonathan Kahana, Yedid Hoshen

Introduction

Representation learning often aims to achieve "domain disentanglement," where a model becomes invariant to specific labeled attributes (the "domain," such as lighting or identity) while remaining highly informative about other unlabeled features (the "content," such as pose or expression). Achieving this balance is difficult; previous approaches typically relied on unstable adversarial training or computationally expensive generative models like Variational Autoencoders (VAEs) and Latent Optimization (e.g., LORD). These methods are often slow to train and struggle to completely eliminate domain-specific information from the latent space.

Methodology: Domain-wise Contrastive Learning

The authors introduce DCoDR (Domain-wise Contrastive Disentangled Representations), a framework that adapts contrastive learning to the disentanglement task. Unlike standard contrastive methods that push an image away from all other images in a batch, DCoDR employs a Domain-wise Contrastive Loss ($L_{inv}$).

Conceptual overview of the domain-wise contrastive loss, where negatives are restricted to the same domain to force invariance.

By restricting "negative" pairs to the same domain, the model is forced to spread representations of each domain uniformly across a unit sphere. This geometric constraint ensures that different domains become indistinguishable in the latent space, achieving high invariance. To prevent the model from ignoring complex features (feature suppression), DCoDR incorporates:

  1. Augmentation Loss ($L_{aug}$): Maintains consistency between an image and its augmented version.
  2. Reconstruction Loss ($L_{rec}$): Uses a conditional generator to rebuild the original image from the representation and domain label.
  3. Pre-trained Initialization: Leverages self-supervised weights (MoCo-V2) to provide a strong starting point.

A variant, DCoDR-norec, removes the reconstruction loss entirely, offering a discriminative-only approach that is significantly faster to train.

Experimental Results

The method was evaluated across five benchmarks: Cars3D, SmallNorb, Shapes3D, CelebA, and Edges2Shoes. DCoDR consistently outperformed state-of-the-art generative models in both invariance and informativeness.

Comparison of DCoDR against baselines across multiple datasets, showing superior invariance (Inv.) and informativeness (Inform.).

Key Performance Metrics

  • Invariance: On Shapes3D, DCoDR achieved near-optimal invariance (0.245), whereas previous methods like LORD (0.703) and ML-VAE (0.999) failed to effectively disentangle the domain.
  • Efficiency: DCoDR-norec provides a 5x to 10x training speedup over LORD. For instance, training on CelebA was reduced from 160 hours to just 9 hours.
  • Cross-Domain Retrieval: The model reached 97% accuracy on Cars3D for tasks requiring the identification of the same object across different domains (e.g., different camera angles).

Discussion and Limitations

A critical insight from this work is the "Augmentation Paradox": while more augmentations generally help self-supervised learning, they can hinder disentanglement if they overlap with the features intended for preservation. For example, horizontal flipping may destroy pose information if pose is the target content.

Despite its success, DCoDR currently requires discrete domain labels and cannot handle continuous variables like varying brightness levels. Additionally, it relies on ImageNet pre-training, introducing an external data dependency. Future work may explore extending this contrastive objective to other modalities like audio or text, which would require identifying domain-safe augmentations.

Summary updated

BibTeX
@inproceedings{kahana2022contrastive,
  author = {Jonathan Kahana and Yedid Hoshen},
  title = {{A Contrastive Objective for Learning Disentangled Representations}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19809-0\_33},
}
Figure