The target distribution
Same three-cluster MoG as the EM tutorial: 100 points each from three anisotropic Gaussians with random seed 42. To DDPM, this is just a tensor of 300 points in , it has no idea three Gaussians produced it.
The forward (noising) process
DDPM defines a fixed Markov chain that gradually adds Gaussian noise to a data point until, after steps, it is indistinguishable from pure noise: is the variance schedule. With and , the chain has a closed-form jump from any directly to : This shortcut is what makes DDPM training cheap: you never simulate the chain step by step during training, you sample , jump straight to , and learn from there.
The reverse (denoising) process
Generation is the forward process run backwards. We learn a Gaussian transition Ho et al. reparameterize the mean by training a network to predict the noise that was added when producing from . The mean is then and the entire variational lower bound collapses to a simple denoising objective: No KL divergence to manage, no encoder, no posterior approximation, pure regression on noise.The noise predictor
For 2D data, is a small MLP. The only non-obvious piece is the time embedding: the network must condition on which timestep we are denoising. The conventional trick is sinusoidal positional features (same idea as transformers).Training
The training loop is one of the simplest in modern generative modeling:- Sample a batch from .
- Sample a random timestep for each example.
- Sample noise and form via the closed-form forward jump.
- Predict .
- Minimize .

Sampling: the reverse process in action
Now run the chain backwards. Start with and, for , take a step: with for and at the final step. The standard variance choice is .
Did it work?
Compare the generated samples to the original training data. The model never learned that there are three components, that they are Gaussian, or where their centers are, it only saw 300 data points and a noise-prediction objective. If the three clusters reappear in the generated cloud, the diffusion model has captured the data distribution.
Connections to other concepts
- Black-box density modeling. DDPM treats as opaque. Compare with EM, which assumes a parametric mixture form and fits its parameters.
- Same recipe, bigger backbone. Replace the 4-layer MLP with a U-Net and the same noise-prediction objective generates 256×256 images. The schedule, the closed-form forward jump, and the training loop do not change.
- Conditional and guided generation. Condition on a label, prompt, or class to obtain conditional models, and combine with classifier-free guidance to trade diversity for fidelity.
- Latent diffusion. Run the entire chain inside a learned latent space (encode → diffuse in latents → decode) for orders-of-magnitude faster image generation.
- Score-based unification. The Score MoG Tutorial trains directly, a network that approximates . DDPM’s noise predictor is, up to a known scaling, a score predictor at the variance-preserving SDE. Same network, different parameterization.
- Faster, deterministic sampling. The DDIM tutorial reuses this same trained model with a different sampler that takes a fraction of the steps and is deterministic, opening the door to latent interpolation and editing.
References
- Ho, Jain, Abbeel. Denoising Diffusion Probabilistic Models. NeurIPS 2020. arxiv.org/abs/2006.11239
- Sohl-Dickstein et al. Deep Unsupervised Learning using Nonequilibrium Thermodynamics. ICML 2015. arxiv.org/abs/1503.03585
- Nichol, Dhariwal. Improved Denoising Diffusion Probabilistic Models. ICML 2021. arxiv.org/abs/2102.09672
PyTorch reference
Found an error on this page? Report an issue.

