VAE
7 memberslucid.models.generative.vaeVAE family — Kingma & Welling, 2013 + Sønderby et al., 2016 hierarchical.
Kingma, Diederik P., and Max Welling. "Auto-Encoding Variational Bayes." International Conference on Learning Representations, 2014.
The Variational Auto-Encoder defines a latent-variable generative model with a standard-normal prior and a neural decoder . Because the marginal likelihood is intractable, training maximises the evidence lower bound (ELBO) instead:
Here is the encoder (the variational posterior). Gradients flow through the stochastic sample via the reparameterization trick — , — which keeps the Monte-Carlo gradient low-variance and pathwise-differentiable. The KL term enjoys the closed form
The β-VAE (Higgins et al., 2017) variant rescales the KL term by a coefficient to trade reconstruction fidelity for posterior compression / latent disentanglement, recovering vanilla ELBO at . The hierarchical / Ladder VAE (Sønderby et al., 2016) extends the latent to a stack , with one extracted per encoder stage and re-injected at the matching decoder resolution; the KL becomes a sum , granting strictly tighter bounds and richer multi-scale priors.
The encoder/decoder backbones here are convolutional with stride-2
down-/up-sampling blocks; the reconstruction term is selectable
between Gaussian (mse) and Bernoulli (bce) likelihoods to match
the data domain. Despite being eclipsed by diffusion on raw sample
quality, the VAE remains the workhorse of representation learning
and a key component inside latent-diffusion pipelines (Stable
Diffusion's first-stage autoencoder).
Classes
Functions
hvae→ VAEModelConstruct a hierarchical (Ladder-style) VAE with one latent per stage.
hvae_gen→ VAEForImageGenerationConstruct a hierarchical VAE with the ELBO loss and prior-sample .generate().
vae→ VAEModelConstruct a convolutional VAE with a single bottleneck latent.
vae_gen→ VAEForImageGenerationConstruct a vanilla VAE with the ELBO loss and prior-sample .generate().