InfoDiffusion: Representation Learning Using
Information Maximizing Diffusion Models

Cornell University Cornell Tech Weill Cornell Medicine
ICML 2023
Top: decoded faces change smoothly between two reconstructed images, Image A and Image B. Bottom: moving along single latent dimensions adds or removes sunglasses, facial hair, and long hair on three faces each.

A semantically meaningful latent space for a diffusion model. InfoDiffusion adds a low-dimensional latent \(\bz\) to a diffusion model. The latent space is smooth (top), and individual dimensions capture disentangled, human-interpretable factors of variation (bottom).

Abstract

While diffusion models excel at generating high-quality samples, their latent variables typically lack semantic meaning and are not suitable for representation learning. Here, we propose InfoDiffusion, an algorithm that augments diffusion models with low-dimensional latent variables that capture high-level factors of variation in the data. InfoDiffusion relies on a learning objective regularized with the mutual information between observed and hidden variables, which is designed to improve latent space quality and to prevent the latents from being ignored by expressive diffusion-based decoders. Empirically, we find that InfoDiffusion learns disentangled and human-interpretable latent representations that are competitive with state-of-the-art generative and contrastive methods, while retaining the high sample quality of diffusion models. Our method enables manipulating the attributes of generated images and has the potential to assist tasks that require exploring a learned latent space to generate quality samples, e.g., generative design.

Diffusion Models with Auxiliary Latents

Diffusion models produce high-quality samples but lack an interpretable low-dimensional latent space. InfoDiffusion adds a low-dimensional auxiliary latent \(\bz\), with a prior \(p(\bz)\), on which every denoising step is conditioned:

\[ p(\bx_{0:T}, \bz) = p(\bx_T)\, p(\bz) \prod_{t=1}^{T} p_\theta(\bx_{t-1} \mid \bx_t, \bz). \]

The noising process does not depend on \(\bz\): \(\bz\) is a representation of the input, not a control variable of diffusion. An encoder \(q_\phi(\bz \mid \bx_0)\) infers it, and applying variational inference twice gives an ELBO \(\mathcal{L}_D\) for the model. The prior can be a simple Gaussian, encode domain knowledge (e.g., a mixture of \(K\) components for \(K\) classes), or be discrete.

Flow chart: the encoder maps x0 to z, which conditions every reverse step p_theta(x_{t-1} | x_t, z) of the diffusion process; mutual information maximization links x0 and z, and prior regularization matches z to a flexible prior p(z).
Auxiliary-variable diffusion with mutual information and prior regularization.

Keeping the latents in use

Auxiliary latents face two risks: an expressive decoder may ignore a low-dimensional \(\bz\) and generate \(\bx_{t-1}\) unconditionally, and the aggregate posterior \(q_\phi(\bz) = \mathbb{E}_{q(\bx_0)}[q_\phi(\bz\mid\bx_0)]\) may fail to match the prior, which degrades both sampling and the latent representation. InfoDiffusion counters them with a mutual-information term and a prior regularizer:

\[ \mathbb{E}_{q(\bx_0)}\big[\mathcal{L}_D(\bx_0)\big] + \zeta \cdot \MI_{\bx_0,\bz} - \beta \cdot \D\big(q_\phi(\bz)\,\|\,p(\bz)\big). \]

Both regularizers are intractable. Following InfoVAE, with \(\lambda := \beta + 1\) the objective can be rewritten in a tractable form:

\[ \mathcal{L}_I = \mathcal{L}_{\text{denoise}} - (1-\zeta)\, \mathbb{E}_{q(\bx_0)}\big[\KL\big(q_\phi(\bz\mid\bx_0)\,\|\,p(\bz)\big)\big] - (\lambda+\zeta-1)\, \KL\big(q_\phi(\bz)\,\|\,p(\bz)\big), \]

where \(\mathcal{L}_{\text{denoise}}\) collects the reconstruction and denoising terms of the ELBO. The KL divergence between \(q_\phi(\bz)\) and \(p(\bz)\) can be replaced by any strict divergence \(\D\) without changing the global optimum, under conditions given in the paper (including \(\zeta \le 1\) and \(\lambda + \zeta - 1 \ge 0\)). We use the maximum mean discrepancy (MMD) with a sum of inverse multiquadratic kernels.

Special cases. With one diffusion step (\(T = 1\)), InfoDiffusion is an InfoVAE, up to the decoder architecture; adding \(\lambda = 1 - \zeta\) gives a \(\beta\)-VAE with \(\beta_{\text{VAE}} = 1 - \zeta\), and \(\zeta = 1\) with an adversarial or MMD divergence gives an adversarial or Wasserstein auto-encoder. With \(\zeta = 1\) and \(\lambda = 0\), both regularizers vanish and a deterministic encoder recovers DiffAE.

The main setting, \((\lambda, \zeta) = (0.1, 0.9)\), satisfies \(\lambda = 1 - \zeta\): the marginal divergence term vanishes, and the objective is that of a \(\beta\)-VAE with \(\beta_{\text{VAE}} = 0.1\) and a diffusion decoder.

Semantic
latents
Discrete
latents
Custom
prior
Max
MI
HQ
samples
AE✗✗✗✗✗
VAE✓✓✓✗✗
\(\beta\)-VAE✓✓✓✗✗
AAE✓✓✓✓✗
InfoVAE✓✓✓✓✗
DDPM✗✗✗✗✓
DiffAE✓✗✗✗✓
InfoDiffusion✓✓✓✓✓

Auto-encoder (top) and diffusion (bottom) frameworks compared with InfoDiffusion.

Implementation

Continuous-time decoder. We use the linear noising process \(\bx_t = (1-t)\,\bx_0 + t\,\beps\), \(t \in [0, 1]\), of rectified flow, and the network predicts the velocity \(\bv_\theta(\bx_t, t, \bz) \approx \beps - \bx_0\). The denoising terms of the ELBO then reduce to a weighted regression loss,

\[ \mathbb{E}_{t,\beps}\Big[\, w(t)\, \big\| \bv_\theta(\bx_t, t, \bz) - (\beps - \bx_0) \big\|^2 \Big], \]

where the weighting \(w(t)\) is set by the distribution of \(t\) (logit-normal on most datasets). The decoder is an ADM-style U-Net. A two-layer MLP embeds \(\bz\), and the embedding modulates every residual block after the time-conditioned adaptive group normalization: \(\bh \leftarrow (1+\bs(\bz)) \cdot \mathrm{AGN}(\bh, t) + \bb(\bz)\).

U-Net decoder: four encoder levels, a middle block with attention and four decoder levels with skip connections; the time embedding and the z embedding (or a null embedding) feed all residual blocks.
The \(\bz\)-conditioned U-Net decoder. The embeddings of \(t\) and \(\bz\) are passed to every residual block. With latent dropout, the embedding of \(\bz\) is replaced by a learned null embedding \(\varnothing\). \(C\) is the base width and \(k\) the channel multiplier of a level.
Left: residual block in which group-normalized features are scaled and shifted first by the time embedding and then by the z embedding. Right: six-block residual MLP with adaptive layer normalization that predicts the velocity of the learned latent prior.
Left: the auxiliary residual block: normalized features are modulated first by the time embedding and then by the embedding of \(\bz\). Right: the velocity network of the learned latent prior.

Encoder. The downsampling half of a U-Net, followed by a linear head on the spatially averaged or flattened final feature map. During training it sees a random resized crop of \(\bx_0\) (70–100% of the side, except on 3DShapes), while the decoder denoises the full image. For \(\zeta = 1\) the encoder is deterministic; for \(\zeta < 1\), as in the main setting, \(q_\phi(\bz\mid\bx_0)\) is a diagonal Gaussian. The noise \(\bx_T\) of an image is inferred by integrating the probability-flow ODE conditioned on its \(\bz\).

Sampling. We draw \(\bz\) either from the prior \(p(\bz)\) or from a learned latent prior, a flow-matching MLP fit to the encodings of the training images (as in DiffAE, a second generative model over \(\bz\)), and integrate the probability-flow ODE with Heun's method. Both samplers can use classifier-free guidance on \(\bz\): the generative models (\(d_z = 256\)) are trained with latent dropout (probability 0.1), and the guided velocity with weight \(w\) is

\[ \bv_\theta(\bx_t, t, \varnothing) + w\, \big( \bv_\theta(\bx_t, t, \bz) - \bv_\theta(\bx_t, t, \varnothing) \big). \]

Discrete latents. Finite scalar quantization (FSQ) bounds and rounds each encoder output to \(L\) levels, \(z_i = \mathrm{round}(c \tanh h_i)/c\) with \(c = (L-1)/2\), with straight-through gradients and a uniform prior over the \(L^{d_z}\) codes. It needs neither a codebook nor auxiliary losses.

Exploring the Latent Space

\(\bz\) captures high-level semantics. Decoding the inferred \(\bz\) of an image with different noise \(\bx_T\) changes its lower-level features, such as the background and hair style.

Three face images in red boxes, each followed by four decodings of its latent z with different noise x_T.
Varying \(\bx_T \sim \mathcal{N}(\bzero, \bI)\) across each row changes lower-level detail. The red box marks the original image.

Smooth interpolation

We encode two images into \((\bz, \bx_T)\) and decode 10 points along a path between them, interpolating \(\bz\) along a quarter circle and \(\bx_T\) spherically. InfoDiffusion combines the smooth interpolation of variational methods with the sample quality of diffusion models.

Interpolations between the same two faces for a VAE, an InfoVAE, DiffAE and InfoDiffusion, with the reconstructed end points in red boxes.
Latent space interpolation for (a) VAE, (b) InfoVAE, (c) DiffAE and (d) InfoDiffusion. Reconstructions of the two original images are at the ends of each row (red boxes).

Disentangled dimensions

The learned latents contain disentangled components: for example, one dimension of \(\bz\) controls smiling. For metrics of disentanglement, see the results below.

Two faces decoded while one latent dimension is traversed: the smile fades from left to right.
A smile dimension. Images produced by a linear traversal along one dimension of \(\bz\), from \(-1.5\) to \(1.5\).

Results

We compare InfoDiffusion to an AE, a VAE, a \(\beta\)-VAE, an InfoVAE and DiffAE on FashionMNIST, CIFAR10, FFHQ, CelebA and 3DShapes. InfoDiffusion uses \((\lambda, \zeta) = (0.1, 0.9)\). Latents are evaluated with \(d_z = 32\) models (\(d_z = 10\) on 3DShapes), and sample quality with \(d_z = 256\) models trained with latent dropout. Latent quality is the held-out accuracy or AUROC of a logistic-regression classifier trained on \(\bz\) (5-fold cross-validation); FID is computed with clean-FID from 10,000 samples against the training set. For InfoDiffusion, ± is the standard deviation over three training seeds. DiffAE is re-trained on every dataset with its official implementation, and the AE, VAE, \(\beta\)-VAE and InfoVAE on FFHQ; the remaining baseline results come from earlier runs with a separate training pipeline.

Informative latents and high-quality samples

FashionMNISTCIFAR10FFHQ
MethodLatent qual. ↑FID ↓Latent qual. ↑FID ↓Latent qual. ↑FID ↓
AE0.819±0.00362.9±2.10.336±0.005169.4±2.40.532±0.002316.7±0.4
VAE0.796±0.00263.4±1.60.342±0.004177.2±3.20.488±0.002307.7±0.1
\(\beta\)-VAE0.779±0.00466.9±1.80.253±0.003183.3±3.10.510±0.001222.6±0.2
InfoVAE0.807±0.00355.0±1.70.357±0.005160.7±2.50.545±0.001195.2±0.5
DiffAE0.822±0.0065.6±0.10.442±0.00434.1±0.10.565±0.00112.1±0.1
InfoDiffusion0.856±0.00422.5±0.60.461±0.00336.2±1.10.628±0.00219.8±0.4
w/ guidance (\(w = 2\))21.9±0.733.7±1.015.7±0.7
w/ learned latent8.1±0.425.7±0.413.1±0.5
w/ learned latent, \(w = 2\)6.8±0.721.3±0.79.8±0.3

Latent quality is classification accuracy (FashionMNIST, CIFAR10) or the average accuracy over age, gender and eyeglasses (FFHQ). InfoDiffusion rows without "learned latent" draw \(\bz \sim p(\bz)\); \(w\) is the guidance weight on \(\bz\). Bold marks the best and underline the second-best value. For the baselines, ± is over cross-validation folds (latent quality) or sample sets (FID). DiffAE and the FFHQ entries of the other baselines are re-trained; the remaining baseline entries come from earlier runs.

The compact latents of InfoDiffusion are the most informative of labels on all three datasets. With latents drawn from the learned latent prior and guidance on \(\bz\), it attains the lowest FID on CIFAR10 and FFHQ and the second lowest on FashionMNIST, after DiffAE.

Disentanglement

3DShapesCelebA
MethodDCI ↑Image qual.TAD ↑Attrs ↑Latent qual. ↑FID ↓
AE0.219±0.001✗0.042±0.0041.0±0.00.759±0.00390.4±1.8
VAE0.276±0.001✗0.000±0.0000.0±0.00.770±0.00294.3±2.8
\(\beta\)-VAE0.281±0.001✗0.088±0.0511.6±0.80.699±0.00199.8±2.4
InfoVAE0.134±0.001✗0.000±0.0000.0±0.00.757±0.00377.8±1.6
DiffAE0.177±0.001✓0.114±0.0332.8±0.40.817±0.0018.4±0.1
InfoDiffusion0.296±0.057✗0.439±0.1345.7±0.60.844±0.00512.1±0.2
w/ guidance (\(w = 2\))11.1±0.3
w/ learned latent✓7.6±0.2
w/ learned latent, \(w = 2\)6.3±0.2

DCI: disentanglement term of the DCI score. Image quality on 3DShapes is judged from 16 samples, drawn with \(\bz \sim p(\bz)\) (first row) or from the learned latent prior. An attribute is captured if some dimension of \(\bz\) detects it with AUROC \(\ge 0.75\); TAD sums, over the captured attributes, the AUROC gap between the two most predictive dimensions, and Attrs counts them. CelebA latent quality is the AUROC averaged over the 40 attributes. DiffAE is re-trained; the other baseline entries come from earlier runs.

On 3DShapes, InfoDiffusion attains the highest DCI disentanglement score (0.296), although the \(\beta\)-VAE and the VAE (0.281 and 0.276) are within one standard deviation across seeds. On CelebA, it captures the most attributes (5.7 on average) with the highest TAD (0.439), while also giving the most informative latents and, with the learned latent prior and guidance, the lowest FID.

Discrete latents

With FSQ latents on CelebA (\(d_z = 32\), \(L = 5\) levels, a uniform prior over \(5^{32}\) codes), latent quality is comparable to that of continuous latents: an average AUROC of 0.849 ± 0.003, a TAD of 0.370 ± 0.240 and 5.6 captured attributes over three seeds, compared with 0.844, 0.439 and 5.7 for continuous InfoDiffusion latents.

Comparison to contrastive methods

CelebAGen.Dim.TAD ↑Latent
qual. ↑
SimCLR†✗20480.192±0.0150.812±0.003
MoCo-v2†✗20480.279±0.0250.846±0.001
DINO†✗3840.000±0.0000.592±0.003
InfoDiffusion✓320.439±0.1340.844±0.005
CelebA,
32 dims
Gen.TAD ↑Attrs ↑Latent
qual. ↑
SimCLR*✗0.062±0.0052.6±0.50.757±0.002
PDAE‡✓0.009±0.0011.0±0.00.767±0.003
InfoDiffusion✓0.439±0.1345.7±0.60.844±0.005

Gen.: whether the model is generative. Dim.: latent dimension. † Weights from the method's PyTorch repository. * Pretrained SimCLR encoder fine-tuned with an added dense layer that projects to 32 dimensions. ‡ Trained by us with the baseline's codebase, in earlier runs.

InfoDiffusion's 32-dimensional latents are comparable to, and in some cases better than, the much larger representations of contrastive methods, and InfoDiffusion is also a generative model. At the same latent size, it outperforms a fine-tuned SimCLR encoder and PDAE, an auto-encoder built on a pretrained diffusion model, on both disentanglement and latent quality.

Choices that matter

Regularization coefficients. Among the settings we evaluate, \((\lambda, \zeta) = (0.1, 0.9)\) gives the most disentangled CelebA latents and the best or second-best FID on all four natural-image datasets, with both samplers; its latents are less informative than those of \(\zeta = 1\) with small \(\lambda\) on CIFAR10 and CelebA. Values \(\zeta > 1\) make the objective unbounded, so we cap \(\zeta = 1\).

Sampling method. Decoding \(\bz \sim p(\bz)\) gives FIDs of 22.5, 36.2, 19.8 and 12.1 on FashionMNIST, CIFAR10, FFHQ and CelebA. The learned latent prior lowers them to 8.1, 25.7, 13.1 and 7.6, and guidance on \(\bz\) (\(w = 2\)) improves FID further with both samplers on all four datasets. The encodings are more concentrated than the prior, so prior draws often fall in regions the decoder has rarely seen.

Like DiffAE, InfoDiffusion obtains its best samples from a learned latent prior rather than from \(p(\bz)\) itself.

Uncurated Samples

The first 64 samples for a fixed random seed, without any selection, from the main configuration (\((\lambda, \zeta) = (0.1, 0.9)\), \(d_z = 256\), first training seed) with guidance \(w = 2\). The FIDs are means over three training seeds. Samples with \(\bz \sim p(\bz)\) contain more distorted faces and less recognizable objects, in line with their higher FIDs.

    Code and Checkpoints

    The implementation described in the paper is available at github.com/yingheng-wang/InfoDiffusion, and the trained checkpoints are on Hugging Face.

    BibTeX

    @inproceedings{wang2023infodiffusion,
      title     = {{InfoDiffusion}: Representation Learning Using Information Maximizing Diffusion Models},
      author    = {Wang, Yingheng and Schiff, Yair and Gokaslan, Aaron and Pan, Weishen and Wang, Fei and De Sa, Christopher and Kuleshov, Volodymyr},
      booktitle = {Proceedings of the 40th International Conference on Machine Learning},
      series    = {Proceedings of Machine Learning Research},
      volume    = {202},
      pages     = {36336--36354},
      publisher = {PMLR},
      year      = {2023}
    }