DDPM: Denoising Diffusion Probabilistic Models

Table of Contents

The prerequisite for this article is Diffusion Models

1. Make Simpler (DDPM): Only Predict Noise

DDPM parameterizes the reverse-process mean through a network that predicts the noise added to \(\mathbf{x}_{0}\). Predicting noise is not the definition of a diffusion probabilistic model—one could instead predict \(\mathbf{x}_{0}\) or the reverse mean directly—but it gives the particularly simple and effective DDPM training objective.

1.1. Forward Process Simplification

Let \(\alpha_{t}:=1-\beta_{t}\) and \( \bar{\alpha}_{t} := \prod_{s=1}^{t} \alpha_{s} \), then we can prove mathematically that the following holds

\begin{equation} \begin{split} q(\mathbf{x}_{t}\mid\mathbf{x}_{0}) &= \mathcal{N}(\mathbf{x}_{t}; \sqrt{\bar{\alpha}_{t}} \mathbf{x}_{0}, (1-\bar{\alpha}_{t})\mathbf{I}) \\ 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}) \end{split} \end{equation}

where 1

\[ \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}, \qquad \tilde{\beta}_{t} := \frac{1-\bar{\alpha}_{t-1}}{1-\bar{\alpha}_{t}}\beta_{t}. \]

Let derive \( q(\mathbf{x}_{t}\mid \mathbf{x}_{0}) \). First, let’s represent \( \mathbf{x}_{2} \) with \( \mathbf{x}_{0} \). By \( \mathbf{x}_{2} = \sqrt{\alpha_{2}} \mathbf{x}_{1} + \sqrt{1-\alpha_{2}}\epsilon_{2} \) and \( \mathbf{x}_{1} = \sqrt{\alpha_{1}} \mathbf{x}_{0} + \sqrt{1-\alpha_{1}}\epsilon_{1} \)

\[ \mathbf{x}_{2} = \sqrt{\alpha_{2}\alpha_{1}}\mathbf{x}_{0} + \left( \sqrt{1-\alpha_{2}}\epsilon_{2} + \sqrt{\alpha_{2}(1-\alpha_{1})}\epsilon_{1} \right) \]

From this equation, the mean is quite obvious. We then check the linear combination of sampled Gaussian noise also follows standard Gaussian. Let \( z=\sqrt{1-\alpha_{2}}\epsilon_{2} + \sqrt{\alpha_{2}(1-\alpha_{1})}\epsilon_{1} \)

Since \( \mathbb{E}[\epsilon_{2}]=\mathbb{E}[\epsilon_{1}]=0 \), their linear combination \( z \) has zero mean.

To check the variance,

\[ \mathrm{Var}[z] = 1-\alpha_{2} + \alpha_{2}(1-\alpha_{1}) = 1-\alpha_{1}\alpha_{2} \]

And since the linear combination of Gaussians is also Gaussian, this means \( z \) follows standard Gaussian.

Let’s drive the posterior \( q(\mathbf{x}_{t-1}\mid \mathbf{x}_{t}, \mathbf{x}_{0}) \). By Bayes’ Rule,

\[ q(\mathbf{x}_{t-1}\mid\mathbf{x}_{t}, \mathbf{x}_{0}) = \frac{ q(\mathbf{x}_{t}\mid\mathbf{x}_{t-1}, \mathbf{x}_{0})q(\mathbf{x}_{t-1}\mid\mathbf{x}_{0}) }{ q(\mathbf{x}_{t}\mid\mathbf{x}_{0}) } \]

Since the forward process is Markovian, we have \( q(\mathbf{x}_{t}\mid\mathbf{x}_{t-1},\mathbf{x}_{0}) = q(\mathbf{x}_{t}\mid\mathbf{x}_{t-1}) \).

Then, if we treat LHS as a function of \( \mathbf{x}_{t-1} \), the denominator of RHS becomes a constant. So

\[ q(\mathbf{x}_{t-1}\mid \mathbf{x}_{t}, \mathbf{x}_{0}) \varpropto q(\mathbf{x}_{t} \mid \mathbf{x}_{t-1}) q(\mathbf{x}_{t-1}\mid \mathbf{x}_{0}) \]

Product of Gaussians is also Gaussian, so we can express the above with

\[ q(\mathbf{x}_{t-1}\mid \mathbf{x}_{t}, \mathbf{x}_{0}) = \mathcal{N}\left( \tilde{\mu_{t}}(\mathbf{x}_{t}, \mathbf{x}_{0}), \tilde{\beta_{t}}\mathbf{I} \right) \]

The prior is chosen as \(p(\mathbf{x}_{T})=\mathcal{N}(0,\mathbf{I})\). With a sufficiently destructive schedule, \(\bar{\alpha}_{T}\approx0\), so \(q(\mathbf{x}_{T}\mid\mathbf{x}_{0})\approx\mathcal{N}(0,\mathbf{I})\). The term \(L_T\) is constant with respect to \(\theta\) because the forward process and its noise schedule are fixed; it is not necessarily exactly zero for finite \(T\).

1.2. Backward Process Simplification

In the original DDPM, the reverse-process variance is fixed rather than learned:

\[ 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}) \]

Two standard choices are \(\sigma_t^2=\beta_t\) and \(\sigma_t^2=\tilde{\beta}_t\). Ho et al. found similar sample quality for both. Fixing the variance is a simplifying design choice, not a claim that the variance contains no useful information; Improved DDPM later learned it to improve likelihood and permit faster sampling.

Thus, we can rewrite the \( L_{t-1} \) term in the loss as

\[ L_{t-1} = \mathbb{E}_{q}\left[ \frac{1}{2\sigma_{t}^{2}} \| \tilde{\boldsymbol{\mu}}_{t}(\mathbf{x}_{t}, \mathbf{x}_{0}) - \mu_{\theta}(\mathbf{x}_{t}, t) \|^{2} \right] + C \]

1.3. DDPM Training

1.3.1. Reparameterization of \( \mathbf{x}_{t} \)

Since \( q(\mathbf{x}_{t}\mid\mathbf{x}_{0}) = \mathcal{N}(\mathbf{x}_{t}; \sqrt{\bar{\alpha}_{t}} \mathbf{x}_{0}, (1-\bar{\alpha}_{t})\mathbf{I}) \), we apply the reparameterization trick to sample \( \mathbf{x}_{t} \) within one step:

\[ \mathbf{x}_{t}(\mathbf{x}_{0}, \boldsymbol{\epsilon}) = \sqrt{\bar{\alpha}_{t}} \mathbf{x}_{0} + \sqrt{1-\bar{\alpha}_{t}} \boldsymbol{\epsilon}, \quad \text{for } \boldsymbol{\epsilon} \sim \mathcal{N}(0, \mathbf{I}) \]

1.3.2. Derivation

We insert \( \mathbf{x}_{0} = \frac{\mathbf{x}_{t}-\sqrt{1-\bar{\alpha}_{t}}\boldsymbol{\epsilon}}{\sqrt{\bar{\alpha}_{t}}} \) into \(\tilde{\boldsymbol{\mu}}_{t}\):

\[ \tilde{\boldsymbol{\mu}}_t(\mathbf{x}_t, \mathbf{x}_0) = \frac{1}{\sqrt{\alpha_t}} \left( \mathbf{x}_t - \frac{\beta_t}{\sqrt{1 - \bar{\alpha}_t}} \boldsymbol{\epsilon} \right). \]

The model predicts the noise:

\[ \boldsymbol{\epsilon}_{\theta}(\mathbf{x}_{t}, t) \approx \boldsymbol{\epsilon}. \]

Therefore the model mean is

\[ \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). \]

Substitution into \(L_{t-1}\) cancels the shared \(\mathbf{x}_{t}\) terms and yields a weighted noise-prediction loss:

\[ L_{t-1} - C = \mathbb{E}_{\mathbf{x}_{0}, \boldsymbol{\epsilon}} \left[ \frac{\beta_{t}^{2}}{2\sigma_{t}^{2}\alpha_{t}(1-\bar{\alpha}_{t})} \left\| \boldsymbol{\epsilon} - \boldsymbol{\epsilon}_{\theta}(\mathbf{x}_{t}, t) \right\|^{2} \right] \]

Ho et al. found that dropping the timestep-dependent weighting improves sample quality:

\[ L_{\text{simple}} = \mathbb{E}_{t,\mathbf{x}_{0}, \boldsymbol{\epsilon}}\left[ \left\| \boldsymbol{\epsilon} - \boldsymbol{\epsilon}_{\theta}(\mathbf{x}_{t}, t) \right\|^{2} \right]. \]

Here \(t\sim\operatorname{Uniform}\{1,\ldots,T\}\), \(\mathbf{x}_{0}\sim q_{\mathrm{data}}\), \(\boldsymbol{\epsilon}\sim\mathcal{N}(0,\mathbf{I})\), and \(\mathbf{x}_{t}\) is obtained with the reparameterization formula. This is a reweighted version of the ELBO terms governing the mean, not the exact negative log-likelihood. In particular, it does not train a learned reverse variance.

The closed form for \(q(\mathbf{x}_{t}\mid\mathbf{x}_{0})\) is crucial: training can sample an arbitrary \(t\) and construct \(\mathbf{x}_{t}\) directly, without simulating the entire chain \(\mathbf{x}_{1},\ldots,\mathbf{x}_{t-1}\).

1.3.3. Training Algorithm

For each optimization step:

  1. Sample \(\mathbf{x}_{0}\sim q_{\mathrm{data}}\).
  2. Sample \(t\sim\operatorname{Uniform}\{1,\ldots,T\}\).
  3. Sample \(\boldsymbol{\epsilon}\sim\mathcal{N}(0,\mathbf{I})\).
  4. Construct \(\mathbf{x}_{t}=\sqrt{\bar{\alpha}_{t}}\mathbf{x}_{0}+\sqrt{1-\bar{\alpha}_{t}}\boldsymbol{\epsilon}\).
  5. Update \(\theta\) using the gradient of \(\|\boldsymbol{\epsilon}-\boldsymbol{\epsilon}_{\theta}(\mathbf{x}_{t},t)\|^{2}\).

1.4. DDPM Sampling

Start from \(\mathbf{x}_{T}\sim\mathcal{N}(0,\mathbf{I})\). At each reverse step, sample from the reverse transition

\[ \mathbf{x}_{t-1} = \boldsymbol{\mu}_{\theta}(\mathbf{x}_{t},t) + \sigma_{t}\mathbf{z} \]

and we plug in the definition of \( \boldsymbol{\mu}_{\theta} \):

\[ \mathbf{x}_{t-1} = \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) + \sigma_{t}\mathbf{z}, \]

where \(\mathbf{z}\sim\mathcal{N}(0,\mathbf{I})\) for \(t>1\), and \(\mathbf{z}=0\) for \(t=1\) so that noise is not added to the final sample.

1.4.1. Sampling Algorithm

  1. Sample \(\mathbf{x}_{T}\sim\mathcal{N}(0,\mathbf{I})\).
  2. For \(t=T,T-1,\ldots,1\):
    • sample \(\mathbf{z}\sim\mathcal{N}(0,\mathbf{I})\) if \(t>1\), otherwise set \(\mathbf{z}=0\);
    • apply the reverse update above.
  3. Return \(\mathbf{x}_{0}\).

Unlike training, ancestral DDPM sampling is sequential and normally requires hundreds or thousands of neural-network evaluations.

2. Noise Schedule and Signal-to-Noise Ratio

The schedule \(\{\beta_t\}_{t=1}^{T}\) controls how quickly information is destroyed. It must satisfy \(0<\beta_t<1\), and is chosen so that \(\bar{\alpha}_{T}\) is close to zero. The original DDPM used a linear \(\beta_t\) schedule; Improved DDPM introduced a cosine schedule for \(\bar{\alpha}_t\).

A useful interpretation is the timestep signal-to-noise ratio

\[ \operatorname{SNR}(t)=\frac{\bar{\alpha}_t}{1-\bar{\alpha}_t}. \]

Early timesteps have high SNR and mostly preserve the data; late timesteps have low SNR and are dominated by noise.

3. Network Parameterization

One neural network is shared across all timesteps. It must therefore receive both the noisy sample \(\mathbf{x}_{t}\) and a representation of \(t\) (or equivalently the noise level). The original image DDPM uses a U-Net-like architecture with sinusoidal timestep embeddings injected into its residual blocks, along with attention at selected resolutions.

Common prediction targets include:

  • \(\boldsymbol{\epsilon}\)-prediction: predict the added noise, as in the original DDPM objective;
  • \(\mathbf{x}_{0}\)-prediction: predict the clean sample directly;
  • \(\mathbf{v}\)-prediction: predict a linear combination of \(\mathbf{x}_{0}\) and \(\boldsymbol{\epsilon}\), often used in later diffusion systems.

These parameterizations contain equivalent information in the idealized setting but can behave differently during optimization.

4. Connection to Denoising Score Matching

The score of the noisy marginal is \(\nabla_{\mathbf{x}_{t}}\log q_t(\mathbf{x}_{t})\). For the conditional Gaussian corruption,

\[ \nabla_{\mathbf{x}_{t}}\log q(\mathbf{x}_{t}\mid\mathbf{x}_{0}) =-\frac{\boldsymbol{\epsilon}}{\sqrt{1-\bar{\alpha}_{t}}}. \]

Consequently, a noise predictor defines a score estimator

\[ \mathbf{s}_{\theta}(\mathbf{x}_{t},t) :=-\frac{\boldsymbol{\epsilon}_{\theta}(\mathbf{x}_{t},t)} {\sqrt{1-\bar{\alpha}_{t}}}. \]

Minimizing the noise-prediction MSE is therefore equivalent, up to timestep-dependent weighting, to denoising score matching. This explains the close relationship between DDPMs and score-based generative models.

5. Practical Details and Limitations

  • Image values are usually scaled to a fixed range such as \([-1,1]\).
  • \(L_0=-\log p_{\theta}(\mathbf{x}_{0}\mid\mathbf{x}_{1})\) is handled as a decoder likelihood; for discrete image values, the DDPM paper uses a discretized Gaussian likelihood.
  • An exponential moving average of model parameters is commonly used for sampling.
  • Diffusion training is stable and easily parallelized across examples, but ancestral sampling is slow because the reverse steps are sequential.
  • Sample quality and likelihood are different objectives: the unweighted \(L_{\mathrm{simple}}\) improves sample quality but is not the tightest likelihood objective.

6. Beyond the Original DDPM

  • Improved DDPM learns the reverse variance, introduces a cosine schedule, and improves likelihood and sampling efficiency.
  • DDIM constructs a non-Markovian reverse process and can sample deterministically with fewer steps.
  • Conditional diffusion incorporates labels, text, or other context; classifier guidance and classifier-free guidance strengthen adherence to the condition.
  • Continuous-time formulations express diffusion using stochastic differential equations, with corresponding reverse-time SDE and probability-flow ODE samplers.
  • Latent diffusion performs denoising in a learned latent space rather than directly in pixel space, greatly reducing computation.

7. References

Footnotes:

1

Why do we need \( q(\mathbf{x}_{t-1}\mid \mathbf{x}_{t},\mathbf{x}_{0}) \)? The image generation model we want has form \( p_{\theta}(\mathbf{x}_{t-1}\mid \mathbf{x}_{t}) \). The training process actually asks the model \( p_{\theta}(\mathbf{x}_{t-1}\mid \mathbf{x}_{t}) \) to approximate analytically known posterior \( q(\mathbf{x}_{t-1}\mid \mathbf{x}_{t}, \mathbf{x}_{0}) \). The extra \( \mathbf{x}_{0} \) in \( q(\cdot) \) but not in \( p_{\theta}(\cdot) \) is intentional because during training, the \( \mathbf{x}_{0} \) is known but during generation, the \( \mathbf{x}_{0} \) is unknown.

Date: 2026-07-27 Mon

Author: ArcaLunar