Diffusion models, specifically the U-Net, are trained to predict the noise present in a noisy input at timestep . This trained model can then be used to generate new data. The Denoising Diffusion Probabilistic Models (DDPM) algorithm provides the original, foundational procedure for this generative process.
As outlined in the chapter introduction, the core idea is to start with pure noise and progressively refine it using the learned denoising steps. We begin by sampling an initial tensor from a standard Gaussian distribution, . This represents maximum entropy, pure noise, corresponding to the end state of the forward diffusion process.
The DDPM sampling algorithm then iteratively applies the learned reverse process, stepping backward from timestep down to . In each step, the goal is to sample a slightly less noisy version given the current state .
Recall from Chapter 3 that the reverse transition is approximated by a Gaussian distribution whose mean depends on and the predicted noise , and whose variance is related to the noise schedule .
The model takes the current noisy image and the timestep as input and outputs its prediction of the noise component that was added to get from to . Using this prediction, we can estimate the mean of the distribution for the previous state . The equation for the mean is derived from the properties of the forward and reverse processes:
Here, and are parameters derived from the noise schedule used during the forward process. This equation essentially takes the current noisy sample and subtracts the scaled predicted noise to estimate the mean of the previous, less noisy state .
The variance of the reverse step, , is also determined by the noise schedule. A common choice, derived to match the variance of the forward process posterior , is:
Note that for . To perform one denoising step and sample from , we calculate the mean using the model's prediction and then add Gaussian noise scaled by the standard deviation :
where is standard Gaussian noise. This added noise introduces stochasticity into the generation process, allowing the model to produce diverse samples even when starting from the same initial (though typically we start from different samples). However, for the very last step (), we usually set to obtain the final deterministic mean prediction as our output .
Putting these steps together, the complete DDPM sampling algorithm proceeds as follows:
This process is visualized below:
Diagram illustrating the iterative DDPM sampling process. Starting from noise , each step uses the noise predictor to compute the mean for the previous state, then samples by adding scaled noise (except for the last step where ).
The quality of the final sample depends heavily on the accuracy of the trained noise predictor and the chosen noise schedule () and number of diffusion steps (). DDPM typically requires a large number of steps (e.g., ) to achieve high-quality results, which can make sampling relatively slow. We will explore faster alternatives like DDIM in the subsequent sections.
Was this section helpful?
© 2026 ApX Machine LearningEngineered with