Learning Disentangled Representation by Exploiting Pretrained Generative Models: A Contrastive Learning View

Xuanchi Ren, Tao Yang, Yuwang Wang, Wenjun Zeng

TL;DR

DisCo (Disentanglement via Contrast) is a novel framework that extracts disentangled features by "interrogating" pretrained generative models. By using contrastive learning to compare image variations caused by different latent directions, DisCo achieves state-of-the-art disentanglement across GANs, VAEs, and Flow models without sacrificing image generation quality.

The Disentanglement Trade-off

In representation learning, "disentanglement" is a highly sought-after property: we want AI models to understand that an image is composed of independent, interpretable factors (e.g., a car's color, model, and orientation). Traditionally, researchers achieve this by adding a regularization term during the training of a generative model, such as a Variational Autoencoder (VAE) or Generative Adversarial Network (GAN).

However, this approach creates a frustrating trade-off: forcing the model to learn disentangled representations often degrades the resulting image quality, leading to blurry or unrealistic outputs.

This paper addresses this conflict by observing that high-quality generative models already contain semantically meaningful variations hidden within their latent spaces. The challenge lies in discovering these variations and training an encoder to recognize them, all without retraining the generator from scratch.

Methods: The DisCo Framework

The authors propose DisCo (Disentanglement via Contrast) to mitigate the quality-disentanglement trade-off. DisCo treats the pretrained generator as a fixed module and focuses entirely on discovering traversal directions and learning representations.

The DisCo Framework

The framework consists of three main components:

  1. The Navigator: A learnable module that proposes candidate "traversal directions" in the latent space of the fixed, pretrained generator.
  2. The $\Delta$-Contrastor: Instead of analyzing raw images, this core module examines the variation between two images (an original image and one shifted along a proposed latent direction). It uses two shared-weight encoders to extract representations and calculates their difference.
  3. Contrastive Learning in "Variation Space": The model is trained using a contrastive loss. It learns to pull together variations caused by the same latent direction (positive pairs) and push away variations caused by different directions (negative pairs).

To optimize this process, the authors introduce two specialized techniques:

  • Entropy-based domination loss: This encourages the encoded representation to be "one-hot," meaning a single latent direction should ideally correspond to exactly one dimension in the learned representation.
  • Hard negatives flipping: In complex models, two different directions might inadvertently control the same semantic attribute. DisCo identifies these "false negatives" and treats them as positive samples to stabilize training.

Key Insights

  • Disentanglement as an Inductive Bias: High-quality pretrained models (like StyleGAN2) already possess an internal structure that is somewhat disentangled. DisCo exploits this existing knowledge rather than fighting against it during training.
  • Variation over Instance: Most contrastive learning methods (like SimCLR) compare different augmented "views" of a single image. DisCo, however, compares the change between images. This shift from "what is in the image" to "how did the image change" is a more natural fit for discovering independent factors of variation.
  • Model Agnostic: Because DisCo treats the generator as a fixed black box, it works equally well whether the underlying architecture is a GAN, a VAE, or a Flow-based model.

Key Results

The framework was evaluated on several standard benchmarks (Shapes3D, MPI3D, Cars3D) and a high-resolution real-world dataset (FFHQ).

Quantitative Results (DCI and MIG)
  • State-of-the-Art Performance: DisCo consistently outperformed previous methods on the MIG (Mutual Information Gap) and DCI (Disentanglement, Completeness, Informativeness) metrics. For example, on the Shapes3D dataset using a GAN, DisCo achieved a DCI of 0.708, significantly higher than the previous best of 0.525.
  • No Quality Loss: Unlike methods such as $\beta$-TCVAE or FactorVAE, which often produce blurry images, DisCo maintains the high-fidelity output of the original pretrained model.
  • Real-World Success: On the FFHQ dataset, DisCo successfully discovered directions for complex attributes like "smile" and "race" while keeping other features (like identity) more stable than competing methods like GANspace or ClosedForm.

Limitations and Future Work

While highly effective, the current "Navigator" assumes that disentangled factors are represented by global linear directions in the latent space. While this holds true for many models, more complex generative architectures might require non-linear "paths."

Additionally, while efficient for GANs and VAEs, training on Flow-based models (like Glow) proved computationally expensive and less stable. Future work may explore extending DisCo to bridge the gap between different model types, such as using a VAE-based encoder to control a high-quality StyleGAN2 generator.

Summary updated

BibTeX
@inproceedings{ren2022learning,
  author = {Xuanchi Ren and Tao Yang and Yuwang Wang and Wenjun Zeng},
  title = {{Learning Disentangled Representation by Exploiting Pretrained Generative Models: A Contrastive Learning View}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=LuovZG3o3ga},
}
Figure