扩散与流匹配:生成模型从零

Diffusion and Flow Matching from Scratch

You use Stable Diffusion but don't get why — on a 2D toy distribution, turn data into noise and back, by hand

6 labs8 AI-mentored sessions~4 hoursBilingual · EN / 中
Start learning →

About this course

A build-it-yourself course: no paper-parroting, no buzzwords. In every session an AI mentor
walks you through writing code, deriving formulas, and dragging sliders — building a
generative model from first principles. Our microscope is a 2D two-moons point cloud:
small enough that every step runs in seconds and is visible to the naked eye, yet real
enough that the math is exactly what Stable Diffusion and Sora run on. You'll melt data
into Gaussian noise step by step (and derive its closed form), train a tiny velocity field
that flows noise back onto the data manifold, then backfill the probability and integration
foundations, derive and run every formula of both flow matching and DDPM, learn to steer
generation (conditioning & guidance), and see exactly what engineering separates 2D toys
from real images. After this course, "diffusion model" is no longer an API to you — it's a
machine whose every screw you have tightened yourself.

What you'll learn

  • Hand-implement the closed-form forward marginal, derive ᾱ_t, and watch a 2D cloud diffuse into a Gaussian
  • Train a tiny-MLP velocity field and sample via Euler/Heun integration, flowing noise back onto the data manifold
  • Derive the conditional flow matching loss and explain why regressing conditional velocities learns the marginal field
  • Derive DDPM's Gaussian posterior and ε-parameterization, implement ancestral sampling and DDIM, and connect diffusion to flow matching
  • Feed labels into the velocity field and implement classifier-free guidance with a single steering knob
  • Account for what separates 2D toys from real images: dimensionality, U-Nets/attention, latent spaces and few-step distillation

Syllabus

1Toy Diffusion: Melt Data into Noise and Back2 sessions
  • 1Melting Data into Noise: the Forward Process30 minStart →
  • 2Flow Matching: Learning to Generate along a Straight Line30 minStart →
2The Probability Toolbox: Distributions, Gaussians & Euler Integration3 sessions
  • 1What Generative Models Learn: Distributions, Sampling & Density30 minStart →
  • 2Gaussian Algebra: Linear Maps, Reparameterization & the Closed-Form Marginal30 minStart →
  • 3Euler Integration: Walking a Vector Field30 minStart →
3Flow Matching: the Velocity-Field Generative Model, Derived3 sessions
  • 1Probability Paths: Every Data Point Drags Its Own Straight Line30 minStart →
  • 2Conditional Flow Matching: Why Regressing One Line Learns the Whole Flow30 minStart →
  • 3Sampler Engineering: Step Counts, Errors, and Smarter Walks30 minStart →
4Denoising Diffusion: DDPM, Scores & Two Ways Home0 sessions

Sessions are on the way.

5Controllable Generation: Conditioning & Classifier-Free Guidance0 sessions

Sessions are on the way.

6Toward the Real World: from 2D Point Clouds to Image Generation0 sessions

Sessions are on the way.

Same series · 人工智能全透析

AI, End to End

Synthesized from the best material across the web — rebuild the core of AI from scratch, the efficient way.