4.5.11Generative Models

Denoising diffusion probabilistic models (DDPM)

3,082 words14 min readdifficulty · medium1 backlinks

Overview

Denoising Diffusion Probabilistic Models (DDPMs) are generative models that learn to create data by reversing a gradual noising process. Instead of directly learning the complex data distribution, they learn to denoise at each step of a Markov chain, making the learning problem tractable.

Why this works: Small denoising steps approximate Gaussian distributions (by Central Limit Theorem), which we know how to model with neural networks.

The Forward Diffusion Process

What It Does

The forward process gradually adds Gaussian noise to data over TT timesteps, destroying structure until only pure noise remains.

q(xtxt1)=N(xt;1βtxt1,βtI)q(\mathbf{x}_t | \mathbf{x}_{t-1}) = \mathcal{N}(\mathbf{x}_t; \sqrt{1-\beta_t}\mathbf{x}_{t-1}, \beta_t \mathbf{I})

where β1,β2,..,βT\beta_1, \beta_2, .., \beta_T is a variance schedule with 0<βt<10 < \beta_t < 1.

Why This Form?

Why multiply by 1βt\sqrt{1-\beta_t}? To control the total variance. If we just added noise N(0,βtI)\mathcal{N}(0, \beta_t\mathbf{I}), variance would grow unboundedly: Var[xt]=Var[xt1]+βt\text{Var}[\mathbf{x}_t] = \text{Var}[\mathbf{x}_{t-1}] + \beta_t. The scaling factor keeps variance stable.

Derivation from scratch: Starting with xt1\mathbf{x}_{t-1} having variance σt12\sigma^2_{t-1}: xt=1βtxt1+βtϵ,ϵN(0,I)\mathbf{x}_t = \sqrt{1-\beta_t}\mathbf{x}_{t-1} + \sqrt{\beta_t}\boldsymbol{\epsilon}, \quad \boldsymbol{\epsilon} \sim \mathcal{N}(0, \mathbf{I})

Then: Var[xt]=(1βt)σt12+βt\text{Var}[\mathbf{x}_t] = (1-\beta_t)\sigma^2_{t-1} + \beta_t

If we want σt2=σt12=1\sigma^2_t = \sigma^2_{t-1} = 1 (unit variance), we need the initial data normalized. This property simplifies the math enormously.

q(xtx0)=N(xt;αˉtx0,(1αˉt)I)q(\mathbf{x}_t | \mathbf{x}_0) = \mathcal{N}(\mathbf{x}_t; \sqrt{\bar{\alpha}_t}\mathbf{x}_0, (1-\bar{\alpha}_t)\mathbf{I})

Why this is powerful: We can sample xt\mathbf{x}_t at ANY timestep directly from x0\mathbf{x}_0 without iterating through all intermediate steps!

Derivation: x1=α1x0+1α1ϵ1\mathbf{x}_1 = \sqrt{\alpha_1}\mathbf{x}_0 + \sqrt{1-\alpha_1}\boldsymbol{\epsilon}_1 x2=α2x1+1α2ϵ2\mathbf{x}_2 = \sqrt{\alpha_2}\mathbf{x}_1 + \sqrt{1-\alpha_2}\boldsymbol{\epsilon}_2

Substituting x1\mathbf{x}_1: x2=α2_1x0+α2(1α1)ϵ1+1α2ϵ2\mathbf{x}_2 = \sqrt{\alpha_2\_1}\mathbf{x}_0 + \sqrt{\alpha_2(1-\alpha_1)}\boldsymbol{\epsilon}_1 + \sqrt{1-\alpha_2}\boldsymbol{\epsilon}_2

Since both noise terms are Gaussian, they combine: α2(1α1)ϵ1+1α2ϵ2=α2(1α1)+(1α2)ϵ\sqrt{\alpha_2(1-\alpha_1)}\boldsymbol{\epsilon}_1 + \sqrt{1-\alpha_2}\boldsymbol{\epsilon}_2 = \sqrt{\alpha_2(1-\alpha_1) + (1-\alpha_2)}\boldsymbol{\epsilon}

Simplifying: α2(1α1)+(1α2)=α2α2α1+1α2=1α1α2\alpha_2(1-\alpha_1) + (1-\alpha_2) = \alpha_2 - \alpha_2\alpha_1 + 1 - \alpha_2 = 1 - \alpha_1\alpha_2

By induction for tt steps: xt=αˉtx0+1αˉtϵ\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon}.

Figure — Denoising diffusion probabilistic models (DDPM)

The Reverse Process (Generation)

What We Want

To generate data, we need to reverse the diffusion: start from noise xTN(0,I)\mathbf{x}_T \sim \mathcal{N}(0, \mathbf{I}) and gradually denoise to x0\mathbf{x}_0.

The true reverse process q(xt1xt)q(\mathbf{x}_{t-1}|\mathbf{x}_t) is intractable because it requires knowing the entire data distribution. But conditioned on x0\mathbf{x}_0, the reverse step is Gaussian!

q(xt1xt,x0)=N(xt1;μ~t(xt,x0),β~tI)q(\mathbf{x}_{t-1}|\mathbf{x}_t, \mathbf{x}_0) = \mathcal{N}(\mathbf{x}_{t-1}; \tilde{\boldsymbol{\mu}}_t(\mathbf{x}_t, \mathbf{x}_0), \tilde{\beta}_t\mathbf{I})

where: μ~t(xt,x0)=αˉt1βt1αˉtx0+αt(1αˉt1)1αˉtxt\tilde{\boldsymbol{\mu}}_t(\mathbf{x}_t, \mathbf{x}_0) = \frac{\sqrt{\bar{\alpha}_{t-1}}\beta_t}{1-\bar{\alpha}_t}\mathbf{x}_0 + \frac{\sqrt{\alpha_t}(1-\bar{\alpha}_{t-1})}{1-\bar{\alpha}_t}\mathbf{x}_t

β~t=1αˉt11αˉtβt\tilde{\beta}_t = \frac{1-\bar{\alpha}_{t-1}}{1-\bar{\alpha}_t}\beta_t

Why this form? It comes from multiplying two Gaussians and completing the square.

Derivation from Bayes: q(xt1xt,x0)q(xtxt1)q(xt1x0)q(\mathbf{x}_{t-1}|\mathbf{x}_t, \mathbf{x}_0) \propto q(\mathbf{x}_t|\mathbf{x}_{t-1})q(\mathbf{x}_{t-1}|\mathbf{x}_0)

Both are Gaussians. For N(x;μ,σ2)\mathcal{N}(\mathbf{x}; \mu, \sigma^2), the log density is 12σ2(xμ)2+const-\frac{1}{2\sigma^2}(\mathbf{x}-\mu)^2 + \text{const}.

Expanding: logq(xtxt1)=12βt(xtαtxt1)2+C1\log q(\mathbf{x}_t|\mathbf{x}_{t-1}) = -\frac{1}{2\beta_t}(\mathbf{x}_t - \sqrt{\alpha_t}\mathbf{x}_{t-1})^2 + C_1

logq(xt1x0)=12(1αˉt1)(xt1αˉt1x0)2+C2\log q(\mathbf{x}_{t-1}|\mathbf{x}_0) = -\frac{1}{2(1-\bar{\alpha}_{t-1})}(\mathbf{x}_{t-1} - \sqrt{\bar{\alpha}_{t-1}}\mathbf{x}_0)^2 + C_2

Sum and collect xt12\mathbf{x}_{t-1}^2 terms to find variance, linear terms to find mean. The algebra yields β~t\tilde{\beta}_t and μ~t\tilde{\boldsymbol{\mu}}_t.

Learned Reverse Process

We approximate the reverse with a neural network:

pθ(xt1xt)=N(xt1;μθ(xt,t),Σθ(xt,t))p_\theta(\mathbf{x}_{t-1}|\mathbf{x}_t) = \mathcal{N}(\mathbf{x}_{t-1}; \boldsymbol{\mu}_\theta(\mathbf{x}_t, t), \Sigma_\theta(\mathbf{x}_t, t))

Training Objective

The Variational Lower Bound

The negative log-likelihood has a variational lower bound:

logpθ(x0)E[logpθ(x0:T)q(x1:Tx0)]=L-\log p_\theta(\mathbf{x}_0) \leq \mathbb{E}\left[-\log \frac{p_\theta(\mathbf{x}_{0:T})}{q(\mathbf{x}_{1:T}|\mathbf{x}_0)}\right] = L

This decomposes into:

L=Eq[DKL(q(xTx0)p(xT))L = \mathbb{E}_q\big[D_{KL}(q(\mathbf{x}_T|\mathbf{x}_0) \| p(\mathbf{x}_T)) +t=2TDKL(q(xt1xt,x0)pθ(xt1xt))+ \sum_{t=2}^T D_{KL}(q(\mathbf{x}_{t-1}|\mathbf{x}_t,\mathbf{x}_0) \| p_\theta(\mathbf{x}_{t-1}|\mathbf{x}_t)) logpθ(x0x1)]- \log p_\theta(\mathbf{x}_0|\mathbf{x}_1)\big]

Why these terms?

  • First term: How far is our final noise from standard Gaussian? (No parameters, ignore)
  • Middle sum: How well does our learned reverse match the true reverse?
  • Last term: Reconstruction likelihood

Lsimple=Et,x0,ϵ[ϵϵθ(xt,t)2]L_{\text{simple}} = \mathbb{E}_{t,\mathbf{x}_0,\boldsymbol{\epsilon}}\left[\|\boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t)\|^2\right]

where xt=αˉtx0+1αˉtϵ\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon} and tUniform(1,T)t \sim \text{Uniform}(1,T).

Why predict noise instead of mean? Because we can reparameterize: μθ(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)

Predicting noise ϵ\boldsymbol{\epsilon} empirically works better than predicting x0\mathbf{x}_0 or μ\boldsymbol{\mu} directly—it's a more stable learning target across timesteps.

Derivation of reparameterization: From xt=αˉtx0+1αˉtϵ\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon}, solve for x0\mathbf{x}_0: x0=xt1αˉtϵαˉt\mathbf{x}_0 = \frac{\mathbf{x}_t - \sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon}}{\sqrt{\bar{\alpha}_t}}

Substitute into μ~t\tilde{\boldsymbol{\mu}}_t formula and simplify using αˉt=αtαˉt1\bar{\alpha}_t = \alpha_t\bar{\alpha}_{t-1} to get the form above.

Step 1: Sample a training image x0\mathbf{x}_0 (e.g., a cat photo, normalized to [1,1][-1,1]).

Step 2: Sample a random timestep t=437t=437 uniformly.

Step 3: Sample noise ϵN(0,I)\boldsymbol{\epsilon} \sim \mathcal{N}(0, \mathbf{I}) with same shape as image.

Step 4: Compute αˉ437=s=1437(1βs)0.542\bar{\alpha}_{437} = \prod_{s=1}^{437}(1-\beta_s) \approx 0.542 (precomputed).

Step 5: Create noised image: x437=0.542x0+10.542ϵ\mathbf{x}_{437} = \sqrt{0.542} \cdot \mathbf{x}_0 + \sqrt{1-0.542} \cdot \boldsymbol{\epsilon}

Step 6: Feed x437\mathbf{x}_{437} and t=437t=437 to network, get prediction ϵθ(x437,437)\boldsymbol{\epsilon}_\theta(\mathbf{x}_{437}, 437).

Step 7: Compute loss: L=ϵϵθ(x437,437)2L = \|\boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta(\mathbf{x}_{437}, 437)\|^2, backpropagate.

Why this step? At t=437t=437, the image is moderately noised. The network learns: "Given this specific noise level and partially corrupted image, predict the exact noise that was added." Over many examples at many timesteps, it learns the full denoising distribution.

Sampling (Generation)

Step 1: Sample xTN(0,I)\mathbf{x}_T \sim \mathcal{N}(0, \mathbf{I}) (pure noise, e.g., 256×256×3256 \times 256 \times 3 tensor of random numbers).

Step 2: For t=T,T1,...,1t = T, T-1, ..., 1:

  • Predict noise: ϵθ(xt,t)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t)
  • Compute mean: μθ=1αt(xtβt1αˉtϵθ(xt,t))\boldsymbol{\mu}_\theta = \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)
  • Sample noise zN(0,I)\mathbf{z} \sim \mathcal{N}(0, \mathbf{I}) if t>1t >1, else z=0\mathbf{z} = 0
  • Update: xt1=μθ+βtz\mathbf{x}_{t-1} = \boldsymbol{\mu}_\theta + \sqrt{\beta_t}\mathbf{z}

Step 3: Return x0\mathbf{x}_0 (generated image).

Why the noise at each step? The reverse process is stochastic—we're sampling from a distribution, not computing a deterministic function. The added noise z\mathbf{z} accounts for uncertainty in the reverse step.

Why noise at t=1t=1? At the final step, we want the mode (most likely value) of pθ(x0x1)p_\theta(\mathbf{x}_0|\mathbf{x}_1), which is the mean.

Key Design Choices

Variance Schedule

Common choices:

  • Linear: βt=β1+t1T1(βTβ1)\beta_t = \beta_1 + \frac{t-1}{T-1}(\beta_T - \beta_1)
  • Cosine: αˉt=f(t)f(0)\bar{\alpha}_t = \frac{f(t)}{f(0)} where f(t)=cos(t/T+s1+sπ2)2f(t) = \cos\left(\frac{t/T + s}{1+s} \cdot \frac{\pi}{2}\right)^2

Network Architecture

Typically a U-Net with:

  • Timestep tt embedded as sinusoidal positional encoding
  • Skip connections to pass both high and low-level features
  • Self-attention layers for capturing global structure

Why U-Net? The denoising task requires both local (texture) and global (object shape) context. U-Net's architecture excels at this.

Advantages of DDPMs

  1. High-quality samples: State-of-art image generation quality (FID scores competitive with GANs)
  2. Stable training: No adversarial dynamics, just regression on noise prediction
  3. Flexible: Easy to condition (class labels, text, etc.) by adding conditioning to ϵθ\boldsymbol{\epsilon}_\theta
  4. Probabilistic: Explicit likelihood bound, unlike GANs

Train with class labels. At generation time:

  • Sample class cc (or choose it)
  • Run sampling algorithm with ϵθ(xt,t,c)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t, c)

Result: Images of the specified class. This extends to text conditioning (text embedings via CLIP) for text-to-image models like Stable Diffusion.

Common Mistakes

The steel-man: For small amounts of noise, single-step denoising (like denoising autoencoders) works fine. The intuition that "simpler is better" is generally sound.

Why it's wrong: Pure noise → structured image is a hugely complex mapping. The distribution p(x0xT)p(\mathbf{x}_0|\mathbf{x}_T) has multimodal, sharply peaked structure—intractable for a single neural network pass. By breaking into TT small steps, each approximates a Gaussian (unimodal, smooth), which networks can model easily.

The fix: Accept the iterative nature. The many steps are what make the problem learnable. (Modern research reduces steps with better schedules and distillation, but fundamentally you need multiple steps.)

Why it's wrong: A bad schedule (e.g., too much noise too fast) makes early timesteps unlearnable—the network can't distinguish signal from noise. A schedule that's too slow wastes capacity on redundant easy denoising steps.

The fix: Use proven schedules (cosine for images). The schedule is a hyperparameter that shapes the curriculum of difficulties the model learns.

Why it's wrong: Empirically, predicting ϵ\boldsymbol{\epsilon} leads to faster convergence and better sample quality. The reason: ϵ\boldsymbol{\epsilon} is a more balanced target across timesteps (same distribution always), while x0\mathbf{x}_0 prediction at high noise levels is poorly constrained.

The fix: Use the noise prediction parameterization (or velocity prediction, a newer variant). Let empirical evidence guide architectural choices.

Connections to Other Concepts

  • Score-based generative models: DDPMs are equivalent to score matching with Langevin dynamics; ϵθ\boldsymbol{\epsilon}_\theta approximates the score xlogp(xt)\nabla_\mathbf{x}\log p(\mathbf{x}_t)
  • Variational Autoencoders (VAE): DDPMs optimize a similar ELBO, but with a fixed encoder (the forward process)
  • Stochastic Differential Equations: The continuous-time limit of DDPMs yields a reverse-time SDE
  • Markov Chain Monte Carlo: Sampling is iterative refinement, similar to MC, but with learned transitions
  • U-Net architecture: The backbone for ϵθ\boldsymbol{\epsilon}_\theta in image DDPMs
  • Classifier-free guidance: Technique to strengthen conditional generation by mixing conditional and unconditional predictions
  • Latent diffusion models: Run diffusion in a compressed latent space (VAE encoder) for efficiency—basis of Stable Diffusion

Or remember: "Forward fuzes, backward builds"—the forward process fuzes images to noise, the backward builds them back.

Recall Explain to a 12-year-old

Imagine you have a beautiful painting, and someone slowly pours sand on it over1000 seconds. Each second, a bit more sand covers the painting, until at the end, you can't see the painting at all—just sand.

Now, what if you had a magic tool that could remove the sand, one second at a time, in reverse? At second 999, it removes a tiny bit of sand and you see a tiny hint of color. At second 500, you can start to see shapes. By second 1, the painting is clear again.

That's what a diffusion model does! The computer learns to be that magic tool. We show it lots of paintings being covered in sand (that's the forward process—adding noise). Then we train it to uncork them, step by step (that's the reverse process—removing noise). Once it's learned, we can start with pure sand (random noise) and let it "uncover" a painting that never existed before—it's creating new art by reversing the destruction process!

The clever part: learning to remove ALL the sand at once is really hard. But learning to remove just a little bit at a time? That's much easier, like cleaning one speck of dust versus cleaning the whole house. So we break the problem into 1000 tiny cleaning steps, and the computer gets really good at each one.

Practice Questions

#flashcards/ai-ml

What is the forward diffusion process in DDPM? :: A Markov chain that gradually adds Gaussian noise to data over T timesteps: q(xtxt1)=N(xt;1βtxt1,βtI)q(\mathbf{x}_t | \mathbf{x}_{t-1}) = \mathcal{N}(\mathbf{x}_t; \sqrt{1-\beta_t}\mathbf{x}_{t-1}, \beta_t \mathbf{I}), destroying structure until only noise remains.

Why does the forward process multiply by 1βt\sqrt{1-\beta_t} instead of just adding noise?
To prevent variance from growing unboundedly. The scaling factor (1βt)(1-\beta_t) for the signal and βt\beta_t for the noise keeps the total variance stable, typically at1.

What is the closed-form for sampling xt\mathbf{x}_t directly from x0\mathbf{x}_0? :: q(xtx0)=N(xt;αˉtx0,(1αˉt)I)q(\mathbf{x}_t | \mathbf{x}_0) = \mathcal{N}(\mathbf{x}_t; \sqrt{\bar{\alpha}_t}\mathbf{x}_0, (1-\bar{\alpha}_t)\mathbf{I}) where αˉt=s=1t(1βs)\bar{\alpha}_t = \prod_{s=1}^t (1-\beta_s). This allows jumping to any timestep without iterating.

What does the DDPM neural network learn to predict?
The noise ϵ\boldsymbol{\epsilon} that was added to create the noisy image xt\mathbf{x}_t from x0\mathbf{x}_0. The network is ϵθ(xt,t)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t).

What is the simplified training objective for DDPM? :: Lsimple=Et,x0,ϵ[ϵϵθ(xt,t)2]L_{\text{simple}} = \mathbb{E}_{t,\mathbf{x}_0,\boldsymbol{\epsilon}}\left[\|\boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t)\|^2\right] where tUniform(1,T)t \sim \text{Uniform}(1,T) and xt=αˉtx0+1αˉtϵ\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\boldsymbol{\epsilon}.

How is ϵθ\boldsymbol{\epsilon}_\theta used to compute the reverse process mean?
μθ(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). This reparameterization connects noise prediction to the mean of the reverse Gaussian.
What is the sampling algorithm for generation?
Start with xTN(0,I)\mathbf{x}_T \sim \mathcal{N}(0,\mathbf{I}). For t=Tt=T to 11: predict noise ϵθ(xt,t)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t,t), compute mean μθ\boldsymbol{\mu}_\theta, sample xt1=μθ+βtz\mathbf{x}_{t-1} = \boldsymbol{\mu}_\theta + \sqrt{\beta_t}\mathbf{z} where zN(0,I)\mathbf{z} \sim \mathcal{N}(0,\mathbf{I}) (or z=0\mathbf{z}=0 for t=1t=1).
Why predict noise instead of the original image x0\mathbf{x}_0?
Empirically, predicting noise ϵ\boldsymbol{\epsilon} is a more stable learning target across timesteps—it has consistent distribution. Predicting x0\mathbf{x}_0 directly at high noise levels is poorly constrained and leads to slower training.

What is the role of the variance schedule {βt}\{\beta_t\}? :: It controls how quickly noise is added in the forward process. A good schedule balances learning difficulty across timesteps—too fast makes early steps unlearnable, too slow wastes capacity on easy steps. Common: linear or cosine schedules.

Why do we need multiple denoising steps instead of one?
The mapping from pure noise to structured data is too complex for a single neural network pass—the distribution is multimodal and sharply peaked. Breaking into T small steps makes each step a simple Gaussian, which networks can model easily.
What architecture is typically used for ϵθ\boldsymbol{\epsilon}_\theta in image DDPMs?
A U-Net with timestep embedings, skip connections, and self-attention layers. U-Net excels at denoising because it captures both local texture and global structure needed to predict noise accurately.
How is DDPM related to score-based generative models?
DDPMs are equivalent to score matching—the noise prediction ϵθ\boldsymbol{\epsilon}_\theta approximates the score function xlogp(xt)\nabla_\mathbf{x}\log p(\mathbf{x}_t) scaled by noise level. Both frameworks describe the same underlying generative process.
How do you condition a DDPM on class labels?
Modify the network to take the class as input: ϵθ(xt,t,c)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t, c). Train with class labels from the dataset. At generation, sample using the desired class cc to produce class-conditional images.
What is classifier-free guidance?
A technique to strengthen conditional generation by mixing conditional and unconditional noise predictions: ϵ~=ϵθ(xt,c)+w(ϵθ(xt,t,c)ϵθ(xt,t))\tilde{\boldsymbol{\epsilon}} = \boldsymbol{\epsilon}_\theta(\mathbf{x}_t,c) + w(\boldsymbol{\epsilon}_\theta(\mathbf{x}_t,t,c) - \boldsymbol{\epsilon}_\theta(\mathbf{x}_t,t)) where ww is guidance weight. Higher ww produces more faithful but less diverse samples.
Why add noise during reverse sampling (the z\mathbf{z} term)?
The reverse process is stochastic—we're sampling from a distribution pθ(xt1xt)p_\theta(\mathbf{x}_{t-1}|\mathbf{x}_t), not computing a deterministic denoising. The added noise accounts for uncertainty in each reverse step and prevents mode collapse.

Concept Map

add Gaussian noise

Markov chain over T steps

uses

scale by sqrt 1-beta_t

reparameterization trick

sample any step directly

learn to un-corrupt

approximated by

small steps are Gaussian by CLT

reverses

defines

defines

Clean data x0

Forward diffusion process

Pure noise xT

Variance schedule beta_t

Stable variance

Closed-form q xt given x0

Cumulative alpha_bar_t

Reverse denoising process

Neural network denoiser

Generated data

DDPM generative model

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, DDPM ka core idea samajhna ho toh ek murtikar (sculptor) ki tarah socho. Sculptor patthar se ekdum se murti nahi banata, woh thoda-thoda extra material hatata jaata hai jab tak form nahi aa jaati. DDPM bilkul ulti direction mein yahi karta hai. Pehle ek clean image lo aur usme dheere-dheere Gaussian noise dalte jao, har step pe thoda sa, jab tak image poori tarah pure noise na ban jaaye — isko forward process kehte hain. Phir model ko sikhaya jaata hai ki is process ko reverse kaise karein, yaani pure noise se shuru karke thoda-thoda noise hatate hue wapas ek clean, structured image tak pahunchein.

Ab yeh trick kaam kyun karti hai, yeh important hai. Directly ek complex data distribution ko learn karna bahut mushkil hai — ek hi shot mein poori image generate karna neural network ke liye tough hai. Lekin agar hum generation ko bahut saare chhote-chhote denoising steps mein tod dein, toh har ek chhota step approximately ek simple Gaussian distribution ban jaata hai, jise neural network aaram se model kar sakta hai. Yahi breakthrough hai: bade problem ko chhote-chhote tractable pieces mein todna. Aur ek badhiya math property yeh hai ki forward process ka closed-form hai — matlab tum kisi bhi timestep tt ka noisy version directly x0\mathbf{x}_0 se nikaal sakte ho, saare beech ke steps loop kiye bina. Isse training kaafi efficient ho jaati hai.

Yeh cheez matter isliye karti hai kyunki aaj ke sabse powerful image generators — jaise Stable Diffusion, DALL-E — inhi diffusion models pe based hain. Jo quality aur variety inme milti hai, woh purane GANs se kaafi behtar aur stable hai. GANs train karna unstable hota tha, par DDPM ka step-by-step denoising approach zyada reliable aur mathematically clean hai. Toh agar tum generative AI mein seriously kaam karna chahte ho, yeh forward-reverse process ka intuition tumhari foundation hai — baaki sab detail isi core idea pe khadi hai.

Go deeper — visual, from zero

Test yourself — Generative Models

Connections