Deriving ELBO and training objective for diffusion models
Diffusion models define a forward Markov chain adding Gaussian noise with variance schedule βₜ:
q(xₜ|xₜ₋₁) = 𝒩(xₜ; √(1–βₜ) xₜ₋₁, βₜ I), with q(xₜ|x₀) = 𝒩(xₜ; √(ᾱₜ) x₀, (1–ᾱₜ) I), where αₜ = 1–βₜ and ᾱₜ = ∏ₛ₌₁^ₜ αₛ.
The reverse generative model p_θ(x₀:ₜ) factorizes as p_θ(x_T) = 𝒩(0, I) and Gaussian transitions p_θ(xₜ₋₁|xₜ) = 𝒩(xₜ₋₁; μ_θ(xₜ,t), σₜ² I).
Maximizing data likelihood log p_θ(x₀) is intractable, so variational inference uses forward q(x₁:ₜ|x₀) as proposal to get the evidence lower bound (ELBO):
log p_θ(x₀) ≥ 𝔼_q[log p_θ(x₀:ₜ) – log q(x₁:ₜ|x₀)].
Expanding yields:
ELBO = –𝐿_T – ∑{t=2}^T 𝐿{t–1} – 𝐿_0, where
𝐿_T = KL(q(x_T|x₀) || p_θ(x_T)),
𝐿_{t–1} = 𝔼_q[KL(q(x_{t–1}|x_t,x₀) || p_θ(x_{t–1}|x_t))],
𝐿_0 = –𝔼_q[log p_θ(x₀|x₁)].
Each q(x_{t–1}|x_t,x₀) is Gaussian with closed form mean and variance computed via Bayes rule from q(xₜ|x₀), enabling exact KL computation.
By parameterizing μ_θ via predicted noise ε_θ(xₜ,t) and fixing variance σₜ², the KL terms simplify to weighted mean squared error between actual ε and predicted ε_θ. This yields the standard simplified training loss:
L_simple = 𝔼_{x₀,ε,t}[||ε – ε_θ(xₜ,t)||²],
with xₜ = √(ᾱₜ) x₀ + √(1–ᾱₜ) ε.
This derivation connects the forward noising, reverse denoising, ELBO optimization, and noise-prediction loss that underlies DDPM training.
A modern “diffusion model” is built out of two Markov chains on the data space:
-
A fixed forward or diffusion chain (q) which starts at a data point (x_0\sim q_{\text{data}}) and injects a small amount of Gaussian noise at each step
[
q(x_t\mid x_{t-1}) = \mathcal{N}!\bigl(x_t;,\sqrt{1-\beta_t},x_{t-1},,\beta_t,\mathbf{I}\bigr),\qquad t=1,\dots,T,
]
with a prescribed variance schedule ({\beta_t}{t=1}^T). Writing (\alpha_t=1-\beta_t) and (\bar\alpha_t=\prod{s=1}^t \alpha_s), this chain has the convenient closed form
[
q(x_t\mid x_0) = \mathcal{N}!\bigl(x_t;,\sqrt{\bar\alpha_t},x_0,,(1-\bar\alpha_t),\mathbf{I}\bigr),
]
so you can obtain (x_t) from (x_0) in one step as (x_t=\sqrt{\bar\alpha_t},x_0+\sqrt{1-\bar\alpha_t},\varepsilon) with (\varepsilon\sim\mathcal{N}(0,I)).
-
A learned reverse chain (p_\theta) which is meant to run this noising process backwards, starting from pure noise (x_T\sim p(x_T)=\mathcal{N}(0,I)) and producing a sample (x_0). It is factorised as
[
p_\theta(x_{0:T}) = p(x_T)\prod_{t=1}^T p_\theta(x_{t-1}\mid x_t),
]
with each reverse transition modelled as a Gaussian
[
p_\theta(x_{t-1}\mid x_t) = \mathcal{N}!\bigl(x_{t-1};,\mu_\theta(x_t,t),,\sigma_t^2,\mathbf{I}\bigr),
]
where (\mu_\theta) is produced by a neural network. A common parameterisation is in terms of a noise predictor (\varepsilon_\theta(x_t,t)), using the identity for the true posterior (q(x_{t-1}\mid x_t,x_0)) to set
[
\mu_\theta(x_t,t)=\frac{1}{\sqrt{\alpha_t}}\biggl(x_t-\frac{\beta_t}{\sqrt{1-\bar\alpha_t}},\varepsilon_\theta(x_t,t)\biggr).
]
Training is framed as maximum likelihood on (p_\theta(x_0)). Because the true posterior (p_\theta(x_{1:T}\mid x_0)) is intractable, Ho et al. use the forward chain (q(x_{1:T}\mid x_0)) as a variational approximation. Applying the usual evidence lower bound (ELBO) gives
[
\log p_\theta(x_0)
=\log\int p_\theta(x_{0:T}),\mathrm{d}x_{1:T}
=\log\int \frac{p_\theta(x_{0:T})}{q(x_{1:T}\mid x_0)},q(x_{1:T}\mid x_0),\mathrm{d}x_{1:T}
]
[
\ge \mathbb{E}{q(x{1:T}\mid x_0)}\bigl[\log p_\theta(x_{0:T})-\log q(x_{1:T}\mid x_0)\bigr];\triangleq; \mathcal{L}_{\text{ELBO}}.
]
Using the Markov factorizations of (p_\theta) and (q) and a bit of algebra to collect terms, this lower bound can be decomposed into a sum of Kullback–Leibler divergences between Gaussian transitions:
[
\mathcal{L}_{\text{ELBO}} = \mathbb{E}q\bigl[-\log p\theta(x_0\mid x_1)\bigr]
- \sum_{t=2}^T \mathbb{E}q\bigl[ \mathrm{KL}\bigl(q(x{t-1}\mid x_t,x_0),|,p_\theta(x_{t-1}\mid x_t)\bigr)\bigr]
- \mathrm{KL}\bigl(q(x_T\mid x_0),|,p(x_T)\bigr).
]
The “true” reverse conditionals (q(x_{t-1}\mid x_t,x_0)) are Gaussian with known mean (\tilde\mu_t(x_t,x_0)) and variance (\tilde\beta_t I), so if you fix the reverse variances (\sigma_t^2) to (\tilde\beta_t), each KL term reduces to a squared error between the model mean and (\tilde\mu_t). Expressed in terms of the noise parameterisation, the dominant part of the ELBO simplifies to the loss used in practice:
[
\mathbb{E}{x_0\sim q{\text{data}},,t\sim{1,\dots,T},,\varepsilon\sim\mathcal{N}(0,I)}\bigl|\varepsilon - \varepsilon_\theta(\sqrt{\bar\alpha_t}x_0+\sqrt{1-\bar\alpha_t},\varepsilon,,t)\bigr|^2,
]
up to weighting factors and additive constants from the other terms. Minimising this mean–squared error trains (\varepsilon_\theta) to predict the injected noise at any diffusion step, which in turn defines the reverse drift (\mu_\theta) and allows the learned chain to denoise iteratively from (x_T\sim\mathcal{N}(0,I)) back to a sample that resembles (q_{\text{data}}).