Autoencoders

An autoencoder learns to copy an input through a constrained intermediate representation. The model has an encoder that maps an input to a latent code and a decoder that reconstructs the input from that code. The useful part is not the copying itself; it is the representation forced through the bottleneck, corruption process, sparsity penalty, or probabilistic latent space.

Autoencoder bottleneck and reconstruction flow

Autoencoders are a form of representation learning and often a form of self-supervised learning, because the input provides its own target. They differ from contrastive learning: contrastive objectives learn by comparing examples, while autoencoders learn by reconstructing missing, noisy, or compressed information.

The encoder-decoder objective

For input , encoder , decoder , and latent code :

A basic reconstruction objective is

If the latent dimension is smaller than the input or otherwise regularized, the model cannot simply memorize every coordinate independently. It must learn a compressed representation that preserves information useful for reconstruction.

Bottleneck Intuition

Suppose an input has 1,000 pixel values and the latent code has 64 numbers. The decoder cannot reconstruct the image by passing all pixels through unchanged. The encoder must store factors such as edges, colors, object layout, or texture statistics in the code. A better reconstruction loss means the code preserved more information that the decoder could use.

That does not automatically mean the code is semantic. A plain autoencoder can spend capacity on background texture or camera noise if those details reduce pixel loss. This is why autoencoders are often paired with corruption, masking, perceptual losses, sparsity, or downstream evaluation.

Important Variants

VariantTraining signalWhat it encourages
Undercomplete autoencoderreconstruct from a smaller latent codecompression and dimensionality reduction
Denoising autoencoderreconstruct clean input from corrupted inputrobustness to noise and missing features
Sparse autoencoderreconstruct while penalizing active unitsinterpretable or factorized latent features
Variational autoencoderreconstruct while matching a latent priorsmooth latent sampling and probabilistic generation
Masked autoencoderreconstruct hidden patches or tokensscalable self-supervised representation learning
Latent autoencodercompress data before another generative modelefficient generation in a learned latent space

Variational Autoencoders

A variational autoencoder turns the latent code into a distribution. The encoder predicts parameters of , the decoder models , and training maximizes the evidence lower bound:

The reconstruction term asks the decoder to explain the data. The KL term keeps the encoded latent distribution close to a simple prior, often a standard normal. This makes sampling possible: draw from the prior and decode it. VAEs usually give smoother latent spaces than plain autoencoders, but samples can look blurrier when the likelihood and decoder are too simple.

Applications

Autoencoders are useful when the objective is compression, reconstruction, anomaly detection, imputation, or representation pretraining:

ApplicationHow the autoencoder is used
Dimensionality reductionreplace high-dimensional inputs with compact latent codes
Denoisingreconstruct clean images, audio, or sensor readings from corrupted inputs
Anomaly detectionflag examples with unusually high reconstruction error
Missing-data imputationinfer masked features from visible context
Self-supervised pretrainingtrain encoders with reconstruction before fine-tuning
Generative modelingsample from a VAE latent prior or decode latents from another model
Latent diffusioncompress images into a latent space before denoising, as in Stable Diffusion

Relevance After Transformers

Transformers did not make autoencoders irrelevant. They changed the preferred architecture for many autoencoding objectives. Masked autoencoders use transformer encoders and decoders to reconstruct missing image patches, and masked-language models are autoencoding in spirit even when their reconstruction target is tokens rather than pixels.

For frontier text-to-image generation, plain VAEs are no longer the dominant generator. Diffusion, flow, and transformer-based generators usually produce better perceptual samples. But many of those systems still depend on autoencoder components: latent diffusion uses an autoencoder to define the image latent space, and representation learning still uses reconstruction when labels are scarce or when missing content is the natural supervision signal.

Caveats

Reconstruction quality can reward the wrong information. A model can reconstruct scanner artifacts, watermarks, sensor noise, or background texture while learning features that transfer poorly. Anomaly detection by reconstruction error can also fail if the autoencoder reconstructs anomalies too well or if normal examples are diverse. Always evaluate the learned representation or error score against the actual downstream task.

Connections

References