Part IV's GAN — short for Generative Adversarial Network — and Part X's VAE — short for Variational Autoencoder — both generate samples from a simple noise source, but neither one tells you the exact probability of any particular output — a VAE only bounds it, a GAN doesn't define one at all. What if the generator were built so that density stayed exactly computable, every step of the way?
Drag . The point traces out the density curve for — not because it's been fit to data, but because it's derived, exactly, from how much stretches space at that .
A normalizing flow builds from a trivial base density by pushing it through an invertible, differentiable function . In one dimension, the change-of-variables formula says exactly how the density transforms:
- — the density of the generated data , computed exactly rather than merely bounded or left undefined.
- — the trivial base density (e.g. uniform) that the flow starts from.
- — the invertible, differentiable function (the flow) that maps a base-space point to a data-space point .
- — the flow's inverse, recovering the base-space point that produced a given .
- — the derivative of at (in higher dimensions, the Jacobian determinant), measuring how much the flow stretches or compresses space there.
- , — a point in data space and its corresponding point in the simple base (latent) space.
- Stretching lowers density
Wherever stretches space (), the same probability mass spreads over a wider region, so density there goes down.
- Compressing raises density
Wherever compresses space (), density goes up — the same mass is packed into a narrower region.
- Total probability is conserved
Mass is only ever redistributed, never created or destroyed — which is exactly what makes the density exactly computable instead of merely bounded.
starts perfectly flat. Squaring it compresses space near (small numbers get squeezed together even harder by squaring) and stretches space near — so density piles up near and thins out near , with no information lost anywhere in between.
The flow , evaluated at two points:
- x = 0.25
. — no stretching or compressing at all here. , identical to the base density.
- x = 0.04
. — space is compressed to less than half its width here. , two and a half times denser than the flat base.
Find the value of x, among the four candidates, with the highest transformed density.
This chapter's flow was one fixed function on one variable, invertible by inspection. Real normalizing flows chain many learned, carefully-designed invertible layers (each engineered so its Jacobian determinant stays cheap to compute even in hundreds of dimensions) to turn a simple base distribution into something that can match real image or audio data — trading the VAE's approximate likelihood and the GAN's absent one for an exact number, at the cost of every layer having to stay invertible. The next chapter drops the invertibility requirement entirely and asks a different question: instead of an exact formula for the density, what if a model just learned which direction increases it?