Course contentsShow
← Machine Learning and Deep Learning
Lesson 1534 of 3,53834. Diffusion ModelsFree lesson

Sampling from Diffusion Models

Understand the iterative sampling procedure that starts from noise and gradually denoises to an image.

Sampling from Diffusion Models

What you'll learn: How diffusion models generate images by starting with pure noise and iteratively removing it step-by-step.

The Core Idea

Sampling from a diffusion model is the process of generating new images from scratch. You begin with a sample of pure random Gaussian noise—think of it as visual static—and then apply the learned reverse diffusion process repeatedly, gradually denoising the image until you arrive at a clean, realistic output.

This is where all your training pays off: the model has learned to predict and remove noise at each timestep, and now you chain these predictions together to transform chaos into structure.

The Iterative Procedure

The sampling process follows these steps:

  1. Start at pure noise: Sample x_T ~ N(0, I), where T is your final timestep (maximum noise level)
  2. Walk backward through time: For each timestep from T down to 1:
    • Feed the current noisy image and the timestep into your trained denoiser
    • The model predicts what noise to remove
    • Update the image by removing that predicted noise
    • Optionally add a small amount of random noise (except at the final step) to maintain proper uncertainty
  3. Output the result: After all timesteps, x_0 is your generated image

Why It Works

Each reverse step undoes a tiny bit of the forward diffusion corruption. Because you trained the model on every intermediate noise level, it knows how to denoise at each stage. The Markov chain structure means each step only depends on the current state, making the process tractable.

Think of it like restoring an old photograph: you don't fix everything at once—you gradually reduce blur, remove scratches, and enhance details in controlled stages.

Key Takeaway: Sampling from diffusion models is an iterative denoising process that starts from pure Gaussian noise and applies the learned reverse diffusion steps sequentially to generate high-quality images.