JA EN
LearnGenerative Models
·★ MEMBER·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.

ModalityimageTaskgeneration

Denoising Diffusion Probabilistic Models

Primary source — what this article is built on

undefined2020-06-19undefined2026-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(xtxt1)=N(xt;1βtxt1, β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(xtxt1)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(xtx0)=N(xt;αˉtx0, (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 10410^{-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 Lt1L_{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 Lt1L_{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.

Reparameterizing Eq. 4 as and expanding reveals what has to predict (Eq. 10):

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

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.

Comments

Sign in to comment