Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Autoencoders learn an encoder that compresses data into a latent code and a decoder that reconstructs the original input. They are a core tool for dimensionality reduction, anomaly detection, and modern generative models (VAEs, diffusion latents).
Formally, an autoencoder is a pair of functions: an encoder Eφ : X → Z and a decoder Dθ : Z → X. Training minimizes reconstruction error:
Undercomplete AEs (dim(Z) < dim(X)) act like compression. With sufficient capacity and an overcomplete latent, the AE can learn the identity unless we add regularization.
Typical setup: X = R^m, Z = R^n with m > n. A simple one-layer encoder is Eφ(x) = σ(Wx + b).
With an L2 reconstruction loss, training becomes least squares:
Linear undercomplete autoencoders recover the same subspace as PCA (up to rotation).
Think of the latent code as a bottleneck. If the bottleneck is small, the model must discard details and keep only the most useful structure.
Reconstruction error can act as an anomaly score: if a point is unlike the training distribution, the AE often reconstructs it poorly.
Depth helps: deep encoders/decoders can represent complex manifolds more efficiently than shallow ones.
This is a small, visual undercomplete autoencoder demo. For linear AEs, the solution matches PCA: compress to 1D along the dominant direction and reconstruct back into 2D. Toggle denoising to see why DAEs learn robust features.
Dark dots are original data. Faint dots are corrupted inputs (only in denoising mode). White circles are reconstructions.
When latent=1D, reconstructions are forced onto a single “manifold direction†(PCA-like). That’s compression.
Outliers (red) tend to reconstruct poorly, which is why reconstruction error can work as an anomaly score.
AEs are trained with gradient descent on reconstruction loss, often with regularization (dropout, sparsity, weight decay).
VAEs require careful balance between reconstruction and KL terms (β-VAE). Too much KL can cause posterior collapse.
For anomaly detection, always validate thresholds: some AEs can reconstruct anomalies surprisingly well.