Deep Learning1 code example
⚡ +100 XP

Diffusion Models

1

What are Diffusion Models?

Diffusion models are the current state-of-the-art in image generation (Stable Diffusion, DALL-E 3, Midjourney). They work by: 1. Forward process: Gradually add Gaussian noise to data over T steps until image becomes pure noise 2. Reverse process: Learn to denoise step by step, starting from pure noise to generate a clean image The model learns: p(x_{t-1} | x_t) — given noisy image at step t, predict less noisy image at step t-1

2

DDPM — Denoising Diffusion Probabilistic Models

Forward: q(x_t | x_{t-1}) = N(x_t; √(1-β_t)·x_{t-1}, β_t·I) β_t is a noise schedule (linear or cosine). After T=1000 steps, x_T ≈ N(0,I). Closed-form shortcut: x_t = √(ᾱ_t)·x_0 + √(1-ᾱ_t)·ε Where ᾱ_t = Π βᵢ and ε ~ N(0,I) The neural network (U-Net) is trained to predict the noise ε given (x_t, t).

3

Classifier-Free Guidance (CFG)

For text-to-image: the model generates both conditioned (text prompt) and unconditioned outputs: ε_guided = ε_uncond + w · (ε_cond − ε_uncond) Guidance scale w controls how strongly the image follows the prompt. Higher w = more prompt-adherent but less diverse.

4

Minimal Diffusion Forward Process

💡

Diffusion models are slower to sample than GANs (need T denoising steps) but produce much higher quality and more diverse outputs.

Finished reading? Mark it complete to earn your XP.