Quiz: generating and exploring images with a VAE
Before this unit: The variational autoencoder (previous unit); Day 36: Neural networks.
See also: Day 30: Snakes and active shape models.
Short questions on generating, interpolating and using a trained VAE. Try each on paper first, then open the answer.
Q1. How do you generate a new image with a trained VAE?
Which part of the network do you need, and where does its input come from?
Draw z from the prior \mathcal N(0, I) and pass it through the decoder. The encoder is not needed.
Q2. True or false: the latent midpoint of two images always decodes to the pixel average of the two images.
True for a linear decoder. Is the VAE decoder linear?
False. A linear decoder (PCA) maps the midpoint to the average, a double exposure. A curved decoder maps it to an in-between shape: a bar halfway, a digit halfway between a 1 and a 7.
Q3. A colleague names the latent axes of a 2D VAE “z_1 = thickness” and “z_2 = slant”. What is the problem?
Does the loss change if the latent space is rotated?
The prior \mathcal N(0, I) and the KL penalty look the same after a rotation of the latent space, so the axes have no fixed meaning; another training run could give rotated or flipped axes. Directions should be read from decoded images along them, and need not line up with the axes.
Q4. Why are the images from a VAE blurrier than the training images?
What single image best matches several different images in squared error?
Several training images share each region of latent space, and the decoder outputs one image for it. The output that minimises the average squared error is their average, and an average of slightly different sharp images is blurred.
Q5. You use reconstruction error to find unusual cells. Name one kind of unusual cell this will catch and one it may miss.
What can the decoder draw?
It catches shapes the decoder cannot draw (a ring, two cells in one crop: large error). It misses unusual cells that happen to look like a normal one in squared error (a square close to a round cell), and small details that change few pixels.
Q6. What does increasing \beta do to generated images and to the latent space?
Stronger pull towards the prior.
The latent space gets smoother and better filled, with directions that often follow one factor each; the images get blurrier and more average.
Q7. A latent diffusion model generates 256 × 256 colour images by working on 32 × 32 × 4 codes of a frozen autoencoder. How many times fewer numbers does it model, and where does the finest detail of its images come from?
Count the numbers; then ask which network turns codes into pixels.
256 \cdot 256 \cdot 3 = 196\,608 against 32 \cdot 32 \cdot 4 = 4\,096: 48 times fewer. The finest detail is drawn by the autoencoder’s decoder, from what it learned in training, not by the model of the codes, and not from any measurement.