DDPM and Improved DDPM
Sources:
- original diffusion model 2015 paper by Jascha Sohl-Dickstein
- DDPM 2020 paper
- Improved DDPM 2021 paper
DDPM and Improved DDPM
TL;DR:
DDPM:
- defines a Gaussian forward diffusion process;
- models reverse transitions as Gaussian distributions;
- predicts noise as a stable parameterization of reverse mean;
- assumes fixed variance.
Improved DDPM:
- keeps the same diffusion framework;
- learns reverse variance;
- provides better uncertainty modeling.
1. Overview
Denoising Diffusion Probabilistic Models (DDPM) introduce a generative modeling framework based on gradually transforming data into Gaussian noise and learning the inverse denoising process.
The key idea is to avoid learning a difficult one-step mapping:
\[ x_T \rightarrow x_0 \]
Instead, DDPM decomposes generation into many local transitions:
\[ x_T \rightarrow x_{T-1} \rightarrow \cdots \rightarrow x_0 \]
Each reverse step only removes a small amount of noise.
The DDPM framework contains two processes:
- Forward diffusion process.
- Reverse denoising process.
2. Notation
| ## Notation |
| Here I list the notations used in the DDPM and Improved DDPM discussion. |
| We follow the common conventions in diffusion models: |
| * Clean data samples are denoted by lower-case italicized Roman letters, such as \(x_0\). * Random variables are denoted by upper-case letters. * Diffusion timesteps are indexed by \(t\), where \(t\in\{1,\dots,T\}\). * Gaussian noise variables are denoted by \(\epsilon\). |
| | Symbol | Meaning | | ——————————- | ———————————————————— | | \(x_0\) | The clean data sample, such as a real image before adding noise. | | \(x_t\) | The noisy sample at diffusion timestep \(t\). It is obtained by gradually corrupting \(x_0\) with Gaussian noise. | | \(T\) | The total number of diffusion timesteps. At timestep \(T\), the sample is approximately distributed as standard Gaussian noise. | | \(t\) | The current diffusion timestep. It controls the noise level of the sample \(x_t\). | | \(\epsilon\) | Gaussian noise sampled from \(\mathcal{N}(0,I)\). It is the noise added to \(x_0\) to construct \(x_t\). | | \(\beta_t\) | The variance of the Gaussian noise added at timestep \(t\) in the forward diffusion process. | | \(\alpha_t\) | The signal coefficient at timestep \(t\), defined as \(\alpha_t=1-\beta_t\). | | \(\bar{\alpha}_t\) | The cumulative product of signal coefficients, defined as \(\bar{\alpha}_t=\prod_{s=1}^{t}\alpha_s\). | | \(q(x_t|x_{t-1})\) | The forward diffusion transition distribution that gradually adds Gaussian noise to the data. | | \(q(x_{t-1}|x_t,x_0)\) | The posterior distribution of the forward diffusion process. It describes the reverse transition when the original clean sample \(x_0\) is known. | | \(p_\theta(x_{t-1}|x_t)\) | The learned reverse diffusion transition distribution used for generation. | | \(\tilde{\mu}_t(x_t,x_0)\) | The true posterior mean of \(q(x_{t-1}|x_t,x_0)\) derived from the forward diffusion process. | | \(\tilde{\beta}_t\) | The true posterior variance of \(q(x_{t-1}|x_t,x_0)\). | | \(\mu_\theta(x_t,t)\) | The neural network prediction of the mean of the reverse diffusion distribution. | | \(\Sigma_t\) | The covariance matrix of the reverse diffusion distribution in the original DDPM formulation. | | \(\sigma_t^2 I\) | The fixed isotropic covariance assumption used by the original DDPM. | | \(\Sigma_\theta(x_t,t)\) | The learned covariance matrix in Improved DDPM. | | \(\epsilon_\theta(x_t,t)\) | The neural network prediction of the Gaussian noise added during the forward diffusion process. | | \(\hat{x}_0\) | The estimated clean sample recovered from the predicted noise \(\epsilon_\theta(x_t,t)\). | | \(v_\theta(x_t,t)\) | The variance prediction parameter introduced in Improved DDPM. It controls the learned reverse variance. | | \(\mathcal{L}_{\epsilon}\) | The epsilon-prediction loss used in DDPM training. | | \(\mathcal{L}_{\mathrm{simple}}\) | The simplified DDPM training objective, usually equivalent to epsilon prediction MSE. | | \(\mathcal{L}_{\mathrm{VLB}}\) | The variational lower bound objective used to train the variance prediction in Improved DDPM. | | \(\mathcal{N}(0,I)\) | The standard Gaussian distribution used as the noise prior. | | \(I\) | The identity matrix. In Gaussian covariance matrices, it represents independent dimensions with equal variance. | | \(\theta\) | The parameters of the denoising neural network. | | \(\lambda\) | The weighting coefficient balancing different loss terms, such as noise prediction loss and variance learning loss. | |
3. Forward Diffusion Process
DDPM first defines a forward noising process:
\[ q(x_t|x_{t-1}) = \mathcal{N} ( \sqrt{1-\beta_t}x_{t-1}, \beta_t I ) \]
At each timestep:
- part of the original signal is preserved;
- Gaussian noise is added.
The process is fixed:
- no neural network is involved;
- no parameters are learned.
After many steps:
\[ x_0 \rightarrow x_1 \rightarrow ... \rightarrow x_T \]
the sample becomes approximately:
\[ x_T\sim\mathcal{N}(0,I) \]
4. Closed-form Sampling of Noisy Data
Although the forward process is a Markov chain, DDPM does not explicitly simulate all forward steps during training.
Because the process is linear Gaussian:
\[ x_t = \sqrt{\bar{\alpha}_t}x_0 + \sqrt{1-\bar{\alpha}_t}\epsilon \]
where:
\[ \epsilon\sim\mathcal{N}(0,I) \]
Therefore, training can directly construct any noisy sample:
clean sample x0 |
without computing:
\[ x_0\rightarrow x_1\rightarrow...\rightarrow x_t \]
5. Reverse Diffusion Process
The goal of DDPM is to learn:
\[ p_\theta(x_{t-1}|x_t) \]
DDPM models each reverse transition as a Gaussian:
\[ p_\theta(x_{t-1}|x_t) = \mathcal{N} ( \mu_\theta(x_t,t), \Sigma_t ) \]
Therefore, the reverse process requires two components:
- Mean:
\[ \mu_\theta(x_t,t) \]
- Covariance:
\[ \Sigma_t \]
The rest of DDPM focuses on how to parameterize and learn these quantities.
6. DDPM Variance Assumption
The original DDPM makes a simplified assumption:
\[ \Sigma_t=\sigma_t^2I \]
This means:
- variance is fixed;
- variance only depends on timestep;
- variance does not depend on the current noisy input;
- all dimensions share the same variance.
Therefore, DDPM mainly learns:
where the reverse process should move.
However, it does not learn:
how uncertain the reverse transition should be.
This limitation motivates Improved DDPM.
7. Learning the Reverse Mean
7.1 Direct Mean Prediction
Since the reverse distribution requires:
\[ \mu_\theta(x_t,t) \]
a natural approach is to directly predict the mean.
The true posterior of the forward process is:
\[ q(x_{t-1}|x_t,x_0) = \mathcal{N} ( \tilde{\mu}_t(x_t,x_0), \tilde{\beta}_tI ) \]
where:
\[ \tilde{\mu}_t(x_t,x_0) = a_t x_0+b_t x_t \]
Therefore:
\[ \mu_\theta(x_t,t) \approx \tilde{\mu}_t(x_t,x_0) \]
is a valid objective.
8. Why DDPM Predicts Noise Instead of Mean
Although mean prediction is mathematically valid, DDPM uses epsilon prediction.
The network predicts:
\[ \epsilon_\theta(x_t,t) \]
instead of:
\[ \mu_\theta(x_t,t) \]
The reason is optimization stability.
The mean target is:
\[ \tilde{\mu}_t = a_t x_0+b_t x_t \]
where:
\[ a_t,b_t \]
change with timestep.
Therefore, different timesteps produce targets with different scales and statistics.
In contrast:
\[ \epsilon\sim\mathcal{N}(0,I) \]
has the same distribution for all timesteps.
Thus epsilon prediction provides a more stable learning target.
9. Epsilon Prediction Objective
The DDPM training objective is:
\[ \mathcal{L}_{\epsilon} = \mathbb{E}_{x_0,t,\epsilon} [ \| \epsilon-\epsilon_\theta(x_t,t) \|^2 ] \]
The model learns to answer:
Given a noisy sample \(x_t\) and timestep \(t\), what Gaussian noise was added?
The noise is known because it is sampled during training.
10. Recovering Clean Data and Reverse Mean
From:
\[ x_t = \sqrt{\bar{\alpha}_t}x_0 + \sqrt{1-\bar{\alpha}_t}\epsilon \]
we can estimate:
\[ \hat{x}_0 = \frac{ x_t-\sqrt{1-\bar{\alpha}_t}\epsilon_\theta(x_t,t) } { \sqrt{\bar{\alpha}_t} } \]
Then:
\[ \epsilon_\theta \rightarrow \hat{x}_0 \rightarrow \mu_\theta \]
Therefore:
Epsilon prediction is not a different generation mechanism. It is a more stable parameterization of the reverse mean.
11. DDPM Training Process
The complete training process:
x0 = sample_real_data() |
Important:
During training:
- no reverse diffusion sampling is performed;
- the model only learns denoising at randomly sampled timesteps.
12. DDPM Sampling Process
During generation:
Start:
\[ x_T\sim\mathcal{N}(0,I) \]
For:
\[ t=T,T-1,...,1 \]
perform:
Step 1
Predict noise:
\[ \epsilon_\theta(x_t,t) \]
Step 2
Compute reverse mean:
\[ \mu_\theta(x_t,t) \]
Step 3
Sample:
\[ x_{t-1} \sim \mathcal{N} ( \mu_\theta, \sigma_t^2I ) \]
After repeating:
\[ x_T\rightarrow...\rightarrow x_0 \]
we obtain a generated sample.
13. Improved DDPM
Improved DDPM keeps the DDPM framework:
- same forward diffusion;
- same reverse Gaussian formulation;
- same epsilon prediction.
The main change is the variance modeling.
14. Learning Reverse Variance
Instead of:
\[ \Sigma_t=\sigma_t^2I \]
Improved DDPM uses:
\[ \Sigma_\theta(x_t,t) \]
The reverse distribution becomes:
\[ p_\theta(x_{t-1}|x_t) = \mathcal{N} ( \mu_\theta(x_t,t), \Sigma_\theta(x_t,t) ) \]
The model predicts:
- Noise component:
\[ \epsilon_\theta(x_t,t) \]
- Variance parameter:
\[ v_\theta(x_t,t) \]
15. Diagonal Covariance Assumption
Improved DDPM does not learn a full covariance matrix.
It still assumes:
\[ \Sigma_\theta = diag(\sigma_1^2,\sigma_2^2,...) \]
Therefore:
\[ Cov(x_i,x_j)=0,\quad i\neq j \]
The improvement is:
DDPM:
\[ \sigma_1^2=\sigma_2^2=...=\sigma_t^2 \]
Improved DDPM:
\[ \sigma_i^2=\sigma_i^2(x_t,t) \]
16. Improved DDPM Objective
The epsilon prediction loss remains:
\[ \mathcal{L}_{simple} = \| \epsilon-\epsilon_\theta(x_t,t) \|^2 \]
An additional variance learning objective is introduced:
\[ \mathcal{L}_{VLB} \]
The final objective:
\[ \mathcal{L} = \mathcal{L}_{simple} + \lambda\mathcal{L}_{VLB} \]
17. DDPM vs Improved DDPM
| DDPM | Improved DDPM | |
|---|---|---|
| Forward process | Fixed Gaussian diffusion | Same |
| Reverse process | Gaussian | Gaussian |
| Mean | Learned | Learned |
| Mean parameterization | Noise prediction | Noise prediction |
| Variance | Fixed \(\sigma_t^2I\) | Learned variance |
| Covariance | Diagonal | Diagonal |
| Output | \(\epsilon_\theta\) | \(\epsilon_\theta+v_\theta\) |