Quiz: conditioning, guidance and latent diffusion
Before this unit: Samplers, steps, and judging the samples (previous unit); Day 41: Modern deep learning; Day 39: Variational autoencoders; Day 5: Deconvolution.
See also: Day 28: Ising model and Markov random fields; Day 35: Gaussian mixtures.
Short questions to test your understanding. Try each on paper first, then open the answer.
Q1. How can a single network provide both the conditional and the unconditional prediction needed for classifier-free guidance?
What happens to the label during training?
During training the label is replaced by “none” at random (say 10 % of the time). The network then learns to denoise both with and without the label; at sampling time it is evaluated twice per step.
Q2. Compute the guided noise prediction for \hat\varepsilon_\text{cond} = 0.3, \hat\varepsilon_\text{uncond} = 0.1, w = 2.
(1+w)\hat\varepsilon_\text{cond} - w\hat\varepsilon_\text{uncond}.
3 \cdot 0.3 - 2 \cdot 0.1 = 0.7.
Q3. Guidance makes samples “more typical” of the class. Typical in which sense?
Most frequent, or most clearly recognisable?
Most clearly recognisable: guidance favours points where the classifier is most certain of the label, i.e. far from the other classes. That is not the most frequent member; with large w it lies beyond the class mean, more extreme than real members.
Q4. Why does recall of a class drop with guidance, while precision may stay high?
Which real members are borderline?
Real members that resemble other classes (borderline) are where the label is uncertain; guidance moves samples away from them, so they are no longer covered (recall drops). The remaining samples still lie on real class members (precision stays high) until w is so large that they leave the data.
Q5. Name two reasons why image generators run diffusion in a latent space.
Cost, and what the diffusion model spends its capacity on.
Far fewer numbers per step (e.g. 48 times), so each step is cheaper; and the diffusion model models layout and content while the autoencoder handles imperceptible pixel detail.
Q6. In a latent diffusion model, where does the finest detail of a generated image come from?
What can the latent represent?
From the decoder: whatever the latent cannot represent is filled in by the decoder’s habits, learned from its training images.
Q7. Why do latent diffusion samples land on realistic codes, whereas decoding draws from the VAE’s \mathcal N(0, I) prior can give nonsense?
Which distribution does each sample from?
The diffusion model learns the actual cloud of training codes (the aggregate posterior). The VAE prior is a round Gaussian that also covers regions with no codes; decoding such points gives shapes no training image had.
Q8. (math) What density does classifier-free guidance target, written with the classifier p(y\mid\mathbf x)?
Bayes in p(\mathbf x\mid y)^{1+w}p(\mathbf x)^{-w}.
p(\mathbf x\mid y)\,p(y\mid\mathbf x)^w (up to normalisation): the class density sharpened by the classifier’s confidence. Applying the combination at every noise level does not sample it exactly.