Disentangling by Factorising

Hyunjik Kim, Andriy Mnih

In the quest for artificial intelligence that "understands" the world like we do, disentangled representations are a holy grail. Imagine a neural network that looks at a picture of a car and assigns one internal "neuron" to its color, another to its orientation, and a third to its model. When you change just the "color" neuron, the car changes color in the reconstruction, but its position and shape stay exactly the same.

While the popular $\beta$-VAE made huge strides in this area, it came with a frustrating "tax": to get better disentanglement, you usually had to sacrifice image quality. In their ICML 2018 paper, Hyunjik Kim and Andriy Mnih introduce FactorVAE, a method that breaks this trade-off by getting surgical with how it penalizes the latent space.

TL;DR

FactorVAE improves upon the $\beta$-VAE by specifically penalizing the Total Correlation—a measure of redundancy—between latent dimensions. This allows the model to achieve superior disentanglement without the "blurriness" or loss of detail typically caused by the heavy-handed penalties in standard $\beta$-VAEs.

What Problem Does This Paper Address?

The standard tool for unsupervised disentanglement is the $\beta$-VAE. It works by adding a multiplier ($\beta$) to the penalty term (the KL divergence) in the Variational Autoencoder objective.

The authors point out a fundamental flaw: the KL penalty in a $\beta$-VAE is a "blunt instrument." It simultaneously penalizes two things:

  1. Mutual Information: The amount of information the latent code $z$ carries about the input $x$. Penalizing this too hard leads to poor reconstructions (blurry images).
  2. Total Correlation (TC): The dependency between the different dimensions of the latent code. Penalizing this is what actually drives disentanglement.

In a $\beta$-VAE, you can't penalize TC without also crushing the Mutual Information. FactorVAE aims to decouple these, penalizing the dependencies between latents while letting the information flow remain high.

Methods

The core innovation is the FactorVAE objective. Instead of just cranking up the $\beta$ value, the authors add a specific term that encourages the distribution of representations to be factorial (meaning the dimensions are independent).

The Total Correlation Penalty

The authors add a penalty based on the KL divergence between the distribution of latent codes $q(z)$ and the product of its marginals $\prod q(z_j)$. If this value is zero, the dimensions are perfectly independent.

The "Density-Ratio Trick"

Calculating Total Correlation directly is mathematically "intractable" (impossible to compute exactly for large datasets). To solve this, the authors borrow a trick from Generative Adversarial Networks (GANs):

FactorVAE Architecture
  • They train a Discriminator (a simple multi-layer perceptron).
  • The Discriminator's job is to distinguish between "real" latent codes and "shuffled" latent codes (where dimensions are randomly permuted across a batch to simulate independence).
  • The VAE is then trained to "fool" the discriminator, effectively forcing its latent dimensions to become independent.

Datasets

The authors evaluated FactorVAE on several benchmarks, ranging from synthetic to real-world:

  • 2D Shapes (dSprites): Procedurally generated hearts, ovals, and squares.
  • 3D Shapes: Objects with varying floor/wall colors and orientations.
  • 3D Faces & 3D Chairs: Standard sets for testing viewpoint and style disentanglement.
  • CelebA: Real-world photos of celebrity faces, used to test if the method scales to complex, "in-the-wild" data.

Key Insights and Ideas

  • Independence $\neq$ Information Loss: You don't need to lose image detail to separate factors of variation. By targeting Total Correlation specifically, FactorVAE achieves a much better "Pareto front" (the trade-off curve) between reconstruction quality and disentanglement.
  • Latent GANs are Stable: While GANs are notoriously hard to train on images, training a discriminator in the low-dimensional latent space of a VAE is surprisingly stable and robust.
  • Metrics Matter: The authors discovered that the existing "Gold Standard" metric for disentanglement (the Higgins metric) had a major loophole—it could report 100% accuracy even if the model hadn't fully disentangled all factors. They proposed a new, more robust metric based on the variance of normalized representations.

Key Results

  • Quantitative Superiority: On the 2D and 3D Shapes datasets, FactorVAE consistently achieved higher disentanglement scores than $\beta$-VAE for any given level of reconstruction error.
Disentanglement vs Reconstruction Error

As shown above, FactorVAE pushes the Pareto front significantly higher. For example, on 2D Shapes, FactorVAE reached a disentanglement score of ~0.82, while $\beta$-VAE plateaued around ~0.73 at the same error level.

  • Qualitative Clarity: Latent traversals (changing one latent variable while keeping others fixed) showed that FactorVAE cleanly separated attributes like "skin tone," "hair length," and "gender" in CelebA, whereas $\beta$-VAE often tangled these attributes together or produced much blurrier faces.

Limitations and Future Work

  • The "Necessary but Not Sufficient" Problem: The authors admit that low Total Correlation is necessary for disentanglement, but it doesn't guarantee it. If all latent dimensions except one collapse to zero, the TC is zero, but you haven't disentangled anything.
  • Discrete Factors: The model still struggles with discrete factors of variation (like "Shape: Square vs. Heart") because it uses continuous Gaussian distributions for the latents. The authors suggest that future work should explore hybrid models that use both discrete and continuous latent variables.
  • Metric Requirements: Their new metric requires the ability to generate samples with specific factors held fixed, which means it can only be used on synthetic datasets where we have a "simulator." Measuring disentanglement on real-world data remains an open challenge.

Summary updated

BibTeX
@inproceedings{kim2018disentangling,
  author = {Hyunjik Kim and Andriy Mnih},
  title = {{Disentangling by Factorising}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=BkZHOjZO-H},
}
Figure