Types of Neural Networks / Autoencoders & VAEs
Autoencoders & VAEs
IntermediateNetworks that learn to compress input into a latent code and reconstruct it.
Architecture
An encoder maps x to a latent code z, and a decoder reconstructs x̂ from z. Undercomplete autoencoders use a lower-dimensional bottleneck to encourage compressed representations; other variants may use larger latent spaces with regularization.
fφ is the encoder and gθ is the decoder. This squared-error reconstruction objective averages over n examples and sums over each example’s features.
Variants
Maximize the evidence lower bound (ELBO), or equivalently minimize its negative as the VAE loss. qφ(z|x) is the approximate posterior, p(z) the prior, and pθ(x|z) the decoder likelihood.
- Denoising AE — reconstructs clean input from corrupted input.
- Sparse AE — enforces sparse activations.
- Variational AE — learns a probabilistic latent space and can generate new samples.
Uses
- Dimensionality reduction
- Anomaly detection
- Denoising
- Generative modelling
Interview questions & answers
Q1. Why might an autoencoder need a bottleneck or regularization?
Answer: Without constraints, an expressive autoencoder can learn an identity mapping instead of useful representations. A lower-dimensional bottleneck, sparsity constraints or a denoising objective encourages it to capture meaningful structure rather than simply copy inputs.
Q2. How does a variational autoencoder differ from a standard autoencoder?
Answer: A standard autoencoder typically maps an input to a deterministic code. A VAE learns an approximate posterior distribution over latent variables and balances reconstruction likelihood with a KL penalty toward a prior. Sampling from the prior and decoding supports generation.
Q3. What is the reparameterization trick?
Answer: For a Gaussian latent posterior, sample standard Gaussian noise and construct the latent value using the learned mean and standard deviation. This separates randomness from the learned parameters, allowing gradients to flow through the sampled latent representation during training.