Diffusion Model Toy illustration

Diffusion Model Toy

Denoising diffusion models (DDPM) learn to generate data by reversing a gradual noising process. Pick a target shape — spiral, two moons, ring, smiley or checkerboard — and scrub the forward slider to watch the blue point cloud dissolve into Gaussian noise over 50 steps of a linear beta schedule, computed in closed form. Press Play to train a small MLP denoiser ε̂(x, t) — the point coordinates plus an 8-dimensional sinusoidal time embedding, one hidden layer of 64 units — with minibatch SGD on the noise-prediction loss, its loss curve drawn live. Then press Sample and watch reverse ancestral sampling animate step by step: 500 orange points condense from static into the target shape next to the real data.

Runs 100% in your browser — models are trained and computed locally on your device.

Notes

  • The forward process has the closed form q(x_t|x_0) = N(√ᾱ_t x_0, (1 − ᾱ_t)I) with ᾱ_t = ∏(1 − β_s), which is why the noise slider can jump to any t instantly.
  • Training minimises the simplified DDPM objective ‖ε − ε̂(x_t, t)‖²: the network only ever learns to guess which noise was added, never the data density itself.
  • Each reverse step computes x_{t−1} = (x_t − β_t/√(1−ᾱ_t) · ε̂)/√α_t + √β_t z, adding fresh noise z at every step except the last — sampling is stochastic by design.
  • With a 64-unit denoiser and 50 steps the generated cloud stays slightly thicker than the real one; longer training and a lower learning rate sharpen it.
  • Runs 100% in your browser — models are trained and computed locally on your device.