Interactive demo · Foundations of Deep Learning · Chapter 20

Classifier-free guidance on a conditional mixture

The data have three classes, the arms of a spiral. One network g(z, w, t, c) was trained with the class replaced by a null value 20% of the time, so it predicts the noise both for p(x | c) and for p(x). Guidance (20.60) samples with the score λ∇ln p(x|c) + (1 − λ)∇ln p(x), that is with the noise prediction λg(c) + (1 − λ)g(∅): λ = 0 ignores the class, λ = 1 is the plain conditional model, λ > 1 pushes samples to where the class is unmistakable. Near the centre the noisy arms overlap, so strong guidance empties the inner end of the arm and narrows the spread.

Class c

Guidance scale λ

Guided score

Steps S (stochastic sampler, η = 1)

Run

Loading the network ...

Try these

Classifier guidance (20.59) adds λ∇ln p(c | zt) to the unconditional score; here the noisy classifier is exact (the data density is a Gaussian mixture), and then (20.58) makes it identical to the exact version of (20.60). Agreement is the mean of p(c | x) under the exact clean classifier; spread is the square root of the trace of the sample covariance. The red curve in the lower panel is the distance from the centre under the density p(x|c)λp(x)1−λ, normalised on a grid.

In the lecture notes