The Decoder as Generative Model
What you'll learn: How the trained VAE decoder transforms random latent codes into new, realistic samples.
The Core Idea
Once your VAE is trained, you have a powerful generative tool: the decoder network p(x|z). Think of it as a reverse mapping machine. During training, the decoder learned to reconstruct images from latent codes. Now, you can generate entirely new samples by feeding it random latent vectors sampled from the prior distribution (typically a standard normal distribution).
Here's the process:
- Sample
z ~ N(0, I)— draw a random point from the prior (a multivariate standard Gaussian) - Pass
zthrough the trained decoder:x_new = decoder(z) - The output
x_newis a brand-new generated sample
Why This Works
The VAE's KL divergence term forced the encoder to organize the latent space to match the prior. This means the decoder learned to produce valid outputs for any latent code drawn from that same prior distribution. You're essentially exploring the "landscape" the decoder has learned, where every point corresponds to a plausible output.
Analogy: Imagine the decoder is a artist who learned to paint faces by studying compressed descriptions. Even if you give them a random description they've never seen (but formatted correctly), they can paint a believable face because they learned the underlying patterns.
Practical Usage
After training, generation is straightforward: sample noise, decode it. You control diversity by how widely you sample in latent space. You can even interpolate between two points to create smooth transitions between generated samples.
Key Takeaway: The trained VAE decoder becomes a standalone generative model—sample random vectors from the prior, decode them, and create new data that resembles your training distribution.