Learn › Generative Models
·FREE·PAPER·9 min read

Diffusion Models from the Ground Up — Add Noise, Then Subtract It

A reading of the DDPM paper (Ho et al., 2020) grounded strictly in its own text: the forward process that adds noise and the reverse process that removes it, why the objective settles into 'predict the noise', how a simplified loss hurt likelihood while improving samples, and what the paper does and does not say about step count.

Key points

  • A diffusion model is a parameterized Markov chain trained using variational inference to produce samples matching the data after finite time.
  • The forward process is fixed, unlearned noise addition, and Eq. 4 lets you jump from the original image to any timestep tt in one shot.
  • In Eq. 10 the only unknown on the right is ϵ\boldsymbol{\epsilon}, so predicting the noise is enough to recover the mean.
  • LsimpleL_{\mathrm{simple}} drops the Eq. 12 weight, is a weighted variational bound, and paired with ϵ\boldsymbol{\epsilon}-prediction reaches IS 9.46 / FID 3.17.
  • Sampling calls the network TT times, so cost is directly proportional to step count, at 17 seconds for a batch of 256 CIFAR10 images.
ModalityimageTaskgeneration

Denoising Diffusion Probabilistic Models

Primary source — what this article is built on

undefined2020-06-19→undefined2026-08-066y 2mo later

Denoising Diffusion Probabilistic ModelsJonathan Ho, Ajay Jain, Pieter Abbeel · 2020-06-19 · v2arXiv:2006.11239Paper page·PDF
undefined

We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN. Our implementation is available at https://github.com/hojonathanho/diffusion


Retracing the path that destroyed the picture

A diffusion model is a parameterized Markov chain trained using variational inference to produce samples matching the data after finite time (§1). Its transitions are learned to reverse a diffusion process — a Markov chain that gradually adds noise to the data until the signal is destroyed.

The design hinge sits right there. As the paper puts it, when the diffusion consists of small amounts of Gaussian noise, it is sufficient to set the sampling chain transitions to conditional Gaussians too, which allows a particularly simple neural network parameterization (§1). Break the destruction into fine enough steps and the reconstruction becomes writable in a simple form.

The forward process: shrink, then add

The forward process is not learned. It is fixed to a variance schedule β1,…,βT\beta_1,\dots,\beta_T (Eq. 2):

q(xt∣xt−1)=N(xt;1−βt xt−1, βtI)q(\mathbf{x}_{t}|\mathbf{x}_{t-1})=\mathcal{N}\left(\mathbf{x}_{t};\sqrt{1-\beta_{t}}\,\mathbf{x}_{t-1},\ \beta_{t}\mathbf{I}\right)
(1)

Swapping the symbols for plain words: q(xt∣xt−1)q(\mathbf{x}_{t}|\mathbf{x}_{t-1}) is the rule that makes the next, slightly dirtier picture out of the one you are holding, and N\mathcal{N} is the instruction which says draw from a bell curve — the two slots after the semicolon being where that bell curve sits and how wide it is. In words: at each step, scale the image down by 1−βt\sqrt{1-\beta_{t}} first, then add noise of variance βt\beta_{t}. Fade the picture a little, sprinkle grit over it — that is the whole step. The scaling is there so that variance does not grow as noise accumulates (Appendix C).

The process has a convenient property. Writing αt=1−βt\alpha_{t}=1-\beta_{t} and αˉt=∏s=1tαs\bar{\alpha}_{t}=\prod_{s=1}^{t}\alpha_{s}, the state at any timestep has a closed form (Eq. 4):

q(xt∣x0)=N(xt;αˉt x0, (1−αˉt)I)q(\mathbf{x}_{t}|\mathbf{x}_{0})=\mathcal{N}\left(\mathbf{x}_{t};\sqrt{\bar{\alpha}_{t}}\,\mathbf{x}_{0},\ (1-\bar{\alpha}_{t})\mathbf{I}\right)
(2)

Here αˉt\bar{\alpha}_{t} is a single number standing for how much of the original picture is still present after tt steps, and 1−αˉt1-\bar{\alpha}_{t} is how much of it has been replaced by noise. Read in words, the formula says the bell curve is centred on the original faded to αˉt\sqrt{\bar{\alpha}_{t}} of its strength, and its width is exactly the part that has been given over to noise. That is, you can jump from the original image to any step in one shot — no thousand-iteration loop — so training can sample tt at random (§2). The experiments use T=1000T=1000 with β\beta increasing linearly from 10−410^{-4} to 0.020.02. Those constants were chosen to be small relative to data scaled to [−1,1][-1,1], keeping the forward and reverse processes approximately the same functional form while pushing the signal-to-noise ratio at xT\mathbf{x}_{T} as low as possible (§4).

The reverse step looks like a small step downhill

The reverse process is a chain of learned Gaussian transitions starting at p(xT)=N(0,I)p(\mathbf{x}_{T})=\mathcal{N}(\mathbf{0},\mathbf{I}) (Eq. 1), trained on the variational bound on negative log likelihood (Eq. 3).

A correspondence the paper points out matters here. Under the ϵ\boldsymbol{\epsilon}-prediction parameterization introduced below, the sampling procedure (Algorithm 2) resembles Langevin dynamics, with ϵθ\boldsymbol{\epsilon}_{\theta} acting as a learned gradient of the data density (§3.2). One step is close to "move a little along a gradient, then add noise".

FIG 1The feel of moving a little at a time along a gradient. This is background for the correspondence in §3.2, where one reverse step resembles a step along a learned gradient — an intuition pump, not a quantity the paper measured

Unfolding the variational bound

The bound is rewritten for variance reduction (Eq. 5) into three kinds of terms: LTL_{T}, the Lt−1L_{t-1} terms, and L0L_{0}. Because the βt\beta_{t} are fixed constants, LTL_{T} is a constant during training and can be ignored (§3.1). The middle terms become tractable once the forward process posterior is conditioned on x0\mathbf{x}_{0} (Eqs. 6 and 7), so every KL divergence is a comparison between Gaussians and has a closed form (§2).

From there Lt−1L_{t-1} reduces to a squared error between μ~t\tilde{\boldsymbol{\mu}}_{t} and μθ\boldsymbol{\mu}_{\theta} (Eq. 8). Read plainly, the network should just predict the posterior mean. That would be the natural stopping point — but the paper rewrites it once more.

The only unknown left is the noise

Reparameterizing Eq. 4 as xt=αˉtx0+1−αˉtϵ\mathbf{x}_{t}=\sqrt{\bar{\alpha}_{t}}\mathbf{x}_{0}+\sqrt{1-\bar{\alpha}_{t}}\boldsymbol{\epsilon} and expanding reveals what μθ\boldsymbol{\mu}_{\theta} has to predict (Eq. 10):

μθ(xt,t)=1αt(xt−βt1−αˉtϵθ(xt,t))\boldsymbol{\mu}_{\theta}(\mathbf{x}_{t},t)=\frac{1}{\sqrt{\alpha_{t}}}\left(\mathbf{x}_{t}-\frac{\beta_{t}}{\sqrt{1-\bar{\alpha}_{t}}}\boldsymbol{\epsilon}_{\theta}(\mathbf{x}_{t},t)\right)
(3)

Read as an instruction, the right-hand side says: take the noisy picture you are holding, subtract the noise the network guessed at — shrunk by the fixed factor βt/1−αˉt\beta_{t}/\sqrt{1-\bar{\alpha}_{t}} — and then divide by αt\sqrt{\alpha_{t}} to undo the shrinking the forward step applied. Which in words is: estimate the grime, wipe off that much, stretch the picture back to size. The point of this equation is that only two things appear on the right: xt\mathbf{x}_{t} and ϵ\boldsymbol{\epsilon}. And xt\mathbf{x}_{t} is already in hand as the network's input, so the only unknown is ϵ\boldsymbol{\epsilon} — predict that and the mean falls out (Eq. 11). Substituting turns the objective into a weighted ∥ϵ−ϵθ∥2\|\boldsymbol{\epsilon}-\boldsymbol{\epsilon}_{\theta}\|^{2} (Eq. 12), which resembles denoising score matching across multiple noise scales (§3.2).

The paper attaches its caveat: this is merely another parameterization of pθp_{\theta}, so its effectiveness is verified in the §4 ablation. Predicting x0\mathbf{x}_{0} directly was also possible, but led to worse sample quality in early experiments.

Training and sampling fit in ten lines

Training (Algorithm 1): draw x0 from the data; draw t uniformly from 1..T
  draw ε ~ N(0, I); take a gradient step on
  || ε - ε_θ(√ᾱ_t x0 + √(1-ᾱ_t) ε, t) ||²

Sampling (Algorithm 2): x_T ~ N(0, I)
  for t = T..1
    z ~ N(0, I)  (z = 0 when t = 1)
    x_{t-1} = (1/√α_t)( x_t - ((1-α_t)/√(1-ᾱ_t)) ε_θ(x_t, t) ) + σ_t z

There is no loop on the training side. Thanks to Eq. 4, one random timestep and one noise draw are enough.

The simplified loss is what raised quality

The paper then drops the weight βt22σt2αt(1−αˉt)\frac{\beta_{t}^{2}}{2\sigma_{t}^{2}\alpha_{t}(1-\bar{\alpha}_{t})} from Eq. 12 entirely (Eq. 14), leaving plain ∥ϵ−ϵθ∥2\|\boldsymbol{\epsilon}-\boldsymbol{\epsilon}_{\theta}\|^{2}. This is not the variational bound but a weighted variational bound, and in the §4 setup it down-weights the small-tt terms. Those terms train the network to denoise data that is barely noisy, so it is beneficial to down-weight them and let the network concentrate on the harder denoising at larger tt (§3.4).

Table 2 shows the effect. Predicting μ~\tilde{\boldsymbol{\mu}} with the true bound and fixed isotropic Σ\boldsymbol{\Sigma} gives IS 8.06 / FID 13.22; predicting ϵ\boldsymbol{\epsilon} under the same conditions gives 7.67 / 13.51 — essentially a tie. But ϵ\boldsymbol{\epsilon}-prediction with LsimpleL_{\mathrm{simple}} jumps to IS 9.46 / FID 3.17. Meanwhile, training μ~\tilde{\boldsymbol{\mu}} on the simplified objective, and learning a diagonal Σ\boldsymbol{\Sigma} under ϵ\boldsymbol{\epsilon}-prediction, were unstable enough that no scores are reported. The noise parameterization and the simplified loss only work as a pair.

Step count against quality

T=1000T=1000 was set so the number of network evaluations during sampling would match prior work, and the paper states it was chosen without a sweep (§4, Appendix B). Sampling calls the network TT times exactly as Algorithm 2 says, so cost is directly proportional to step count. Measured: 17 seconds for a batch of 256 CIFAR10 images, 300 seconds for 128 images at 256×256256\times256 (Appendix B).

On length itself, what the paper says is this: the Gaussian diffusion length is not restricted to the data dimension, and can be made shorter for fast sampling or longer for model expressiveness (§4.3). Predicting x^0\hat{\mathbf{x}}_{0} partway through the reverse process also shows large-scale features appearing first and details last.

The allocation of rate and distortion is measured too. In Table 4, running the reverse process to completion gives a rate of 1.776 bits/dim at RMSE 0.951, while at 900 steps remaining it is 0.120 bits/dim at RMSE 12.02. Most of the bits go to describing imperceptible distortion (§4.3). Note, though, that this is an analysis of a progressive lossy code, not a measurement of image quality when sampling is cut short.

Limits and open questions

Stated by the paper itself:

On overfitting, the paper argues from a train-test codelength gap of at most 0.03 bits/dim that the model is not overfitting (§4.3).

FIG 2A widening gap between training and test error is the signature of overfitting. DDPM points to a gap in codelength of at most 0.03 bits/dim as evidence that it is not overfitting (§4.3)

Note as of writing (2026) — an author's remark, not a claim of the paper: all numbers are this paper's own from 2020. Few-step samplers and diffusion in latent space are outside its scope and are not included here.

How this shows up on the job

Engineers meet diffusion models when continuing training of a released model on their own data, or training one from scratch on a narrow domain. Rederiving the theory is rare; the values below go straight into a config file.

The knobs. T (the number of diffusion steps), the β\beta schedule (linear 10−4→0.0210^{-4}\to0.02), EMA decay 0.9999, dropout (swept on CIFAR10 and set to 0.1), learning rate 2×10−42\times10^{-4}, batch 128 (64 at 2562256^2). Self-attention sits between the convolutional blocks at 16×1616\times16 resolution, and the timestep tt enters each residual block as a Transformer sinusoidal position embedding (Appendix B).

Ways to get hurt. (1) Keeping the learning rate at high resolution makes training unstable — the paper drops to 2×10−52\times10^{-5} at 2562256^2. (2) Assuming that learning the reverse variances must help; it breaks (Table 2). (3) EMA and dropout were used at unswept defaults, so behaviour without them is outside what the paper covers. (4) Generation cost scales with step count, one network call per step. (5) FID is 3.17 against the training set and 5.24 against the test set — never compare numbers without matching that reference (§4.1).

Questions that come up in interviews. "Why predict the noise?" — Eq. 10 shows the quantity μθ\boldsymbol{\mu}_{\theta} must produce is a linear combination of xt\mathbf{x}_{t} and ϵ\boldsymbol{\epsilon}, and xt\mathbf{x}_{t} is already the input, so ϵ\boldsymbol{\epsilon} is the only unknown (Eq. 11); it also matches the form of denoising score matching (§3.2). "How does LsimpleL_{\mathrm{simple}} differ from the bound?" — it drops the weight in Eq. 12, so small-tt terms count for less, which costs likelihood and buys sample quality (§3.4). The probability background is in probability and statistics for AI, and how to read bits/dim is in information theory for AI.

Summary

Original paper: Ho, Jain, Abbeel, "Denoising Diffusion Probabilistic Models" (arXiv:2006.11239, 2020 / v2)

🎬 Watch this explained (Manim, captioned)

References

  1. Jonathan Ho, Ajay Jain, Pieter Abbeel. (2020-06-19) Denoising Diffusion Probabilistic Models. arXiv:2006.11239Paper page·PDF

This article is written from the source paper above. Where they differ, the original is authoritative.

Published by TechAthletes · Editorial policy · How we cite · Corrections

Comments

Sign in to comment