Back to Projects

Deconstructing VAEs from Scratch

Explore the mathematics of variational inference, latent spaces, and the reparameterization trick — built entirely from scratch in pure PyTorch.

Part 1

The Math of Latent Spaces

Breaking down the ELBO derivation, KL divergence, variational inference, and why you can't just backpropagate through sampling.

Part 2

PyTorch Implementation

Building Encoder, Decoder, reparameterization, and ELBO loss with both dense and convolutional variants — entirely from scratch.
View Code on GitHub

Part 3

Walking Through Latent Space

Visualizing latent space structure, interpolating between digits, and comparing reconstruction quality across latent dimensions.