Reverse Process & Denoising

Volume III, Chapter 10 — Part II. Tractable posterior q(x_{t-1} given x_t and x_0), variational lower bound, ε-prediction parameterization, score matching connection, and DDPM sampling theory.

Advanced

Table of Contents

  1. Learning Objectives
  2. Prerequisites
  3. Notation
  4. Core Intuition
  5. The Reverse Process
  6. Tractable Posterior
  7. The Variational Lower Bound
  8. KL Between Gaussians and Mean Matching
  9. The ε-Prediction Parameterization
  10. The Simplified DDPM Loss
  11. Connection to Score Matching
  12. Alternative Parameterizations
  13. Sampling the Reverse Process
  14. Worked Examples
  15. Connection to the Broader Curriculum
  16. Common Pitfalls and Misconceptions
  17. Research Perspective
  18. Summary of Takeaways
  19. Exercises

Learning Objectives

After reading this chapter, you should be able to:

  1. Define the learned reverse process pθ(xt1xt)p_\theta(\mathbf{x}_{t-1} \mid \mathbf{x}_t) and explain why q(xt1xt)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t) alone is intractable.
  2. Derive the tractable posterior q(xt1xt,x0)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t, \mathbf{x}_0) and its mean μ~t\tilde{\boldsymbol{\mu}}_t and variance β~t\tilde{\beta}_t.
  3. Decompose the variational lower bound (VLB) into KL terms LT,Lt1,L0L_T, L_{t-1}, L_0.
  4. Show that training reduces to matching posterior means, then to ϵ\boldsymbol{\epsilon}-prediction.
  5. Connect ϵθ\boldsymbol{\epsilon}_\theta to the score function xtlogq(xt)\nabla_{\mathbf{x}_t} \log q(\mathbf{x}_t).
  6. State the simplified DDPM loss and sampling update.

Prerequisites


Notation

  • pθ(xt1xt)p_\theta(\mathbf{x}_{t-1} \mid \mathbf{x}_t) — Learned reverse transition
  • ϵθ(xt,t)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t) — Predicted noise network
  • x0,xT\mathbf{x}_0, \mathbf{x}_T — Data and pure noise endpoints
  • xtlogq(xt)\nabla_{\mathbf{x}_t} \log q(\mathbf{x}_t) — Score function
  • Lsimple\mathcal{L}_{\mathrm{simple}} — Denoising training objective

Core Intuition

Forward Diffusion destroys structure by adding noise. Generation requires inverting this process: starting from xTN(0,I)\mathbf{x}_T \sim \mathcal{N}(\mathbf{0}, \mathbf{I}), iteratively denoise to recover x0\mathbf{x}_0.

The true reverse q(xt1xt)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t) requires marginalizing over all data — intractable. But conditioning on x0\mathbf{x}_0 yields a tractable Gaussian posterior q(xt1xt,x0)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t, \mathbf{x}_0). Training matches the learned reverse pθp_\theta to this posterior.

The remarkable result: the VLB reduces to predicting the noise ϵ\boldsymbol{\epsilon} added during the forward process — a simple MSE loss justifying DDPM training.

Series context. Volume III, Chapter 10, Part II.

Reverse Denoising Process

t = 1.00 (T→0)
Timestep
100
Data pointsScore ∇log p(x)
Explore: Reverse diffusion learns a score function pointing toward data. As t decreases, noisy samples follow these arrows to recover structured clusters.

The Reverse Process

Definition 1 (Learned Reverse).

pθ(xt1xt)=N(xt1;μθ(xt,t),σt2I),(1)p_\theta(\mathbf{x}_{t-1} \mid \mathbf{x}_t) = \mathcal{N}(\mathbf{x}_{t-1}; \boldsymbol{\mu}_\theta(\mathbf{x}_t, t), \sigma_t^2 \mathbf{I}), \tag{1}

where μθ\boldsymbol{\mu}_\theta is a neural network and σt2\sigma_t^2 is typically fixed to β~t\tilde{\beta}_t (posterior variance).

Proposition 1 (Anderson, 1982). For infinitesimal forward steps, the reverse-time SDE is a diffusion with drift depending on the score xlogq(xt)\nabla_{\mathbf{x}} \log q(\mathbf{x}_t).

Proposition 2 (Intractability). q(xt1xt)=q(xt1,x0xt)dx0q(\mathbf{x}_{t-1} \mid \mathbf{x}_t) = \int q(\mathbf{x}_{t-1}, \mathbf{x}_0 \mid \mathbf{x}_t)\, d\mathbf{x}_0 requires knowledge of the data distribution.


Tractable Posterior

Theorem 1 (Posterior). By Bayes' rule on the Markov forward chain, the conditional q(xt1xt,x0)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t, \mathbf{x}_0) is Gaussian:

q(xt1xt,x0)=N(xt1;μ~t(xt,x0),β~tI),(2)q(\mathbf{x}_{t-1} \mid \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}), \tag{2}

where

μ~t=αˉt1βt1αˉtx0+αt(1αˉt1)1αˉtxt,(3)\tilde{\boldsymbol{\mu}}_t = \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, \tag{3} β~t=1αˉt11αˉtβt.(4)\tilde{\beta}_t = \frac{1-\bar{\alpha}_{t-1}}{1-\bar{\alpha}_t}\,\beta_t. \tag{4}

Proof sketch. Product of Gaussians q(xtxt1)q(xt1x0)q(\mathbf{x}_t \mid \mathbf{x}_{t-1}) \cdot q(\mathbf{x}_{t-1} \mid \mathbf{x}_0); complete the square in xt1\mathbf{x}_{t-1}. Precision:

1β~t=αtβt+11αˉt1=1αˉtβt(1αˉt1).(5)\frac{1}{\tilde{\beta}_t} = \frac{\alpha_t}{\beta_t} + \frac{1}{1-\bar{\alpha}_{t-1}} = \frac{1-\bar{\alpha}_t}{\beta_t(1-\bar{\alpha}_{t-1})}. \tag{5}

Mean from linear terms. \blacksquare


The Variational Lower Bound

Theorem 2 (VLB).

logpθ(x0)Eq[logpθ(x0:T)q(x1:Tx0)]=LVLB,(6)\log p_\theta(\mathbf{x}_0) \geq \mathbb{E}_{q}\left[\log \frac{p_\theta(\mathbf{x}_{0:T})}{q(\mathbf{x}_{1:T} \mid \mathbf{x}_0)}\right] = -\mathcal{L}_{\text{VLB}}, \tag{6} LVLB=DKL(q(xTx0)p(xT))+t=2TDKL(q(xt1xt,x0)pθ(xt1xt))E[logpθ(x0x1)].(7)\mathcal{L}_{\text{VLB}} = D_{\text{KL}}(q(\mathbf{x}_T \mid \mathbf{x}_0) \| p(\mathbf{x}_T)) + \sum_{t=2}^{T} D_{\text{KL}}(q(\mathbf{x}_{t-1} \mid \mathbf{x}_t, \mathbf{x}_0) \| p_\theta(\mathbf{x}_{t-1} \mid \mathbf{x}_t)) - \mathbb{E}[\log p_\theta(\mathbf{x}_0 \mid \mathbf{x}_1)]. \tag{7}

Interpretation:

  • LTL_T: prior match (≈ 0 when q(xT)N(0,I)q(\mathbf{x}_T) \approx \mathcal{N}(\mathbf{0}, \mathbf{I}))
  • Lt1L_{t-1}: main denoising terms
  • L0L_0: reconstruction

KL Between Gaussians and Mean Matching

With σt2=β~t\sigma_t^2 = \tilde{\beta}_t (fixed variance):

Proposition 3.

DKL(qpθ)=12β~tμ~t(xt,x0)μθ(xt,t)2.(8)D_{\text{KL}}(q \| p_\theta) = \frac{1}{2\tilde{\beta}_t}\|\tilde{\boldsymbol{\mu}}_t(\mathbf{x}_t, \mathbf{x}_0) - \boldsymbol{\mu}_\theta(\mathbf{x}_t, t)\|^2. \tag{8}

Training = match posterior mean.


The ε-Prediction Parameterization

From Forward Diffusion:

xt=αˉtx0+1αˉtϵ.(9)\mathbf{x}_t = \sqrt{\bar{\alpha}_t}\,\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\,\boldsymbol{\epsilon}. \tag{9}

Solving for x0\mathbf{x}_0 and substituting into (3):

μ~t=1αt(xtβt1αˉtϵ).(10)\tilde{\boldsymbol{\mu}}_t = \frac{1}{\sqrt{\alpha_t}}\left(\mathbf{x}_t - \frac{\beta_t}{\sqrt{1-\bar{\alpha}_t}}\,\boldsymbol{\epsilon}\right). \tag{10}

Definition 2 (ϵ\boldsymbol{\epsilon}-Prediction).

μθ(xt,t)=1αt(xtβt1αˉtϵθ(xt,t)).(11)\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). \tag{11}

Proposition 4.

Lt1ϵϵθ(xt,t)2.(12)L_{t-1} \propto \|\boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t)\|^2. \tag{12}

The Simplified DDPM Loss

Definition 3 (DDPM Simple Loss, Ho et al.).

Lsimple=Et,x0,ϵ[ϵϵθ(αˉtx0+1αˉtϵ,t)2].(13)\mathcal{L}_{\text{simple}} = \mathbb{E}_{t, \mathbf{x}_0, \boldsymbol{\epsilon}}\left[\|\boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta(\sqrt{\bar{\alpha}_t}\,\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\,\boldsymbol{\epsilon}, t)\|^2\right]. \tag{13}

Dropping time-dependent weights improves sample quality empirically.

Training algorithm:

  1. Sample x0\mathbf{x}_0, tt, ϵ\boldsymbol{\epsilon}
  2. Compute xt\mathbf{x}_t via (9)
  3. Minimize ϵϵθ(xt,t)2\|\boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t)\|^2

Connection to Score Matching

Theorem 3 (Score–Noise Identity).

xtlogq(xtx0)=ϵ1αˉt.(14)\nabla_{\mathbf{x}_t} \log q(\mathbf{x}_t \mid \mathbf{x}_0) = -\frac{\boldsymbol{\epsilon}}{\sqrt{1-\bar{\alpha}_t}}. \tag{14}

Corollary 2. ϵθ\boldsymbol{\epsilon}_\theta estimates the score (scaled):

ϵθ(xt,t)=1αˉtsθ(xt,t).(15)\boldsymbol{\epsilon}_\theta(\mathbf{x}_t, t) = -\sqrt{1-\bar{\alpha}_t}\,\mathbf{s}_\theta(\mathbf{x}_t, t). \tag{15}

Connects DDPM to score-based models (Song & Ermon, 2019).


Alternative Parameterizations

  • ϵ\boldsymbol{\epsilon} — Noise — Standard DDPM
  • x0\mathbf{x}_0 — Clean data — Direct reconstruction
  • v\mathbf{v}αˉtϵ1αˉtx0\sqrt{\bar{\alpha}_t}\boldsymbol{\epsilon} - \sqrt{1-\bar{\alpha}_t}\mathbf{x}_0 — Stable Diffusion XL

All related by linear transforms of (xt,t)(\mathbf{x}_t, t).


Sampling the Reverse Process

Definition 4 (DDPM Sampling Step). Given xt\mathbf{x}_t and predicted ϵθ\boldsymbol{\epsilon}_\theta:

xt1=1αt(xtβt1αˉtϵθ)+β~tz,zN(0,I).(16)\mathbf{x}_{t-1} = \frac{1}{\sqrt{\alpha_t}}\left(\mathbf{x}_t - \frac{\beta_t}{\sqrt{1-\bar{\alpha}_t}}\,\boldsymbol{\epsilon}_\theta\right) + \sqrt{\tilde{\beta}_t}\,\mathbf{z}, \quad \mathbf{z} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}). \tag{16}

Start from xTN(0,I)\mathbf{x}_T \sim \mathcal{N}(\mathbf{0}, \mathbf{I}), iterate t=T,,1t = T, \ldots, 1.


Worked Examples

Example 1: Posterior Mean at High Noise

When αˉt0\bar{\alpha}_t \approx 0, μ~txt/αt\tilde{\boldsymbol{\mu}}_t \approx \mathbf{x}_t / \sqrt{\alpha_t} — mostly depends on current noisy state.

Example 2: Score from Noise

If ϵθ=ϵ\boldsymbol{\epsilon}_\theta = \boldsymbol{\epsilon} exactly, score estimate is exact for conditional q(xtx0)q(\mathbf{x}_t \mid \mathbf{x}_0).


Connection to the Broader Curriculum


Common Pitfalls and Misconceptions

Pitfall 1: Confusing q(xt1xt)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t) with q(xt1xt,x0)q(\mathbf{x}_{t-1} \mid \mathbf{x}_t, \mathbf{x}_0).

Pitfall 2: Using wrong variance σt2\sigma_t^2 in sampling.

Pitfall 3: Assuming Lsimple\mathcal{L}_{\text{simple}} is the exact ELBO.


Research Perspective

DDPM (Ho et al., 2020). Score SDE (Song et al., 2021). DDIM deterministic sampling. Consistency models. Flow matching as alternative.


Summary of Takeaways

  • Posterior — Gaussian with μ~t\tilde{\boldsymbol{\mu}}_t, β~t\tilde{\beta}_t
  • VLB — Sum of KL mean-matching terms
  • Training —ϵϵθ 2\ — \boldsymbol{\epsilon} - \boldsymbol{\epsilon}_\theta\ — ^2
  • Scoreϵθlogq\boldsymbol{\epsilon}_\theta \propto -\nabla \log q

Next: Classifier-Free Guidance


Exercises

Exercise 1. Derive (3)–(4) from product of Gaussians.

Exercise 2. Derive (10) from (3) and (9).

Exercise 3. Prove (14).

Exercise 4. Show (11) and (12) are equivalent objectives.

Exercise 5. Derive sampling step (16).

Exercise 6. Why is LT0L_T \approx 0?

Exercise 7. Compare ϵ\boldsymbol{\epsilon} vs. x0\mathbf{x}_0 parameterization numerically.

Exercise 8. Connect to Gradient Descent on (13).