Syllabus Lesson 174 of 246 · Module 15: Squeeze, rebuild, generate (autoencoders and VAEs)
Module 15: Squeeze, rebuild, generate (autoencoders and VAEs)

Walking from one digit to another

Why it matters If the code space has no gaps, the straight line between two codes should pass through pictures that are digits all the way. That is a direct test of what pull 2 bought, and the basis of every "morph" you have seen from image generators.

Take two test digits, a and b. Their codes are mu_a and mu_b. A latent walk decodes the points mu_a + t (mu_b - mu_a) for t from 0 to 1. Compare it with the obvious alternative, a cross-fade in pixels: (1 - t) a + t b, which only blends two inks.

Watch the scene: the same walk drawn both ways, frame by frame, with each frame's closeness to the nearest real digit beside it.

Then measure it over many pairs, not one: take 200 pairs of different digits and judge the halfway points (t = 0.5) of each method.

Words and symbols in this lesson
code (latent)
the few numbers the encoder makes from one picture
VAE
variational autoencoder: an autoencoder whose codes are pulled to fill N(0, 1), so random codes decode to new pictures
mu, logvar
the centre and the log of the squared spread of a code number in a VAE
closeness, variety
the course judge: distance to the nearest real digit, and bits of spread over the ten digits
latent walk
decoding points on the straight line between two codes
Your turn

Write walk(model, a, b, steps) returning steps pictures from a to b through the code space (the first and last are the decoded codes of a and b). Then fill halfway with the closeness of the 200 halfway pictures for the VAE walk and for the cross-fade.

Spotted a problem in this lesson? Report it · Ask about this lesson

This exercise opens soon

Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.