Vision & Multimodal
Diffusion Models
How learning to invert a noise process became the dominant generative recipe for images, video, and audio, and why Flow Matching and DiTs are reshaping the recipe in 2024.
advanced · 10 min read · Premium
A GAN trains a generator and a discriminator in adversarial equilibrium; the training is notoriously unstable and the samples often collapse to a few modes. Diffusion models replace the adversarial game with a much simpler problem: given an image with noise added, predict the noise. Iterate the denoising step and you have a generator. The objective is a clean regression, training is stable, the samples cover modes, and the resulting framework now underlies Stable Diffusion, DALL-E 3, Sora, Veo, Suno, and most of the generative-media stack.
The forward process
Pick a sequence of T timesteps and a noise schedule beta_1, ..., beta_T (typically linear or cosine, increasing). At each step you add a tiny bit of Gaussian noise to the image:
q(x_t | x_{t-1}) = N(x_t; sqrt(1 - beta_t) * x_{t-1}, beta_t * I)
A useful identity: you can jump straight from x_0 to x_t in closed form:
x_t = sqrt(alpha_bar_t) * x_0 + sqrt(1 - alpha_bar_t) * eps, eps ~ N(0, I)
where alpha_bar_t = prod_{s=1..t} (1 - beta_s). At t = T (typically 1000) the image is essentially pure noise. The forward process has no learnable parameters - it is a fixed corruption.
The reverse process as a learned vector field
The generator is the reverse of this chain. You want p_theta(x_{t-1} | x_t). Ho et al's 2020 DDPM showed that, given a small enough beta_t, the reverse step is also Gaussian, and the only thing you need to predict is the mean. Reparameterising, predicting the noise eps that was added is equivalent and works better in practice:
loss = E_{t, x_0, eps} || eps - eps_theta(x_t, t) ||^2
That is the entire training objective. Pick a random timestep, add the corresponding amount of noise to a clean image, ask the network to predict the noise. Sampling at inference is the reverse iteration: start from x_T ~ N(0, I), predict eps, subtract a scaled version, add a small fresh noise, repeat for 1000 steps. DDIM (Song et al, 2020) showed you can skip most steps and still get good samples - 20-50 steps is now standard, and distilled variants run in 1-4 steps.
DDPM vs the score-based view
There are two ways to look at the same algorithm:
- DDPM (Ho 2020). Discrete-time Markov chain; predict the noise.
- Score-based (Song & Ermon 2019, Song 2020). Continuous-time SDE; predict the score
grad_x log p_t(x)of the noisy distribution.
The two formulations are equivalent up to reparameterisation. The score view connects diffusion to a body of older statistical theory (Langevin dynamics, score matching) and makes some manipulations (guidance, conditioning, accelerated sampling) cleaner. The DDPM view is operationally simpler. Most practitioners read the score-based paper for intuition and write the DDPM code.
Keep reading with Pro.
You're reading the preview. Unlock the full concept plus the library, study plans, the AI mentor, and daily emails.