What is an autoencoder?
An autoencoder is a neural network trained without labels, made of an encoder that compresses the input into a smaller internal representation and a decoder that tries to rebuild the input from it.
It differs from a variational autoencoder in the kind of representation: a standard autoencoder maps each input to a single point and is not designed to generate new samples, while the variational type learns a probabilistic latent space that can. It differs from the general encoder-decoder architecture in that the target is the input itself.
- Topic
- Machine learning, models and training
- Also known as
- Auto-encoder
How an autoencoder works
- In the standard form the encoder compresses high-dimensional input into a low-dimensional representation in a narrow layer called the bottleneck.
- The decoder rebuilds the input from that representation as closely as possible.
- Training minimises the reconstruction error between input and output; no labels are needed.
- The bottleneck forces the model to learn the main patterns rather than copy; after training the encoder alone can extract representations.
In more detail
Undercomplete and overcomplete autoencoders
Autoencoders fall into two structural families: undercomplete autoencoders restrict capacity via a narrower bottleneck dimension, whereas overcomplete autoencoders use a latent layer wider than the input and rely on regularisation, such as L1 or TopK sparsity (Sparse Autoencoders), input corruption (Denoising Autoencoders) or Jacobian penalties (Contractive Autoencoders), to extract meaningful features.
Loss functions
Training minimises a reconstruction loss such as Mean Squared Error (MSE) for continuous inputs or Binary Cross-Entropy for normalised or binary data, optionally plus a regularisation term. Choosing the right loss and output activation strongly affects anomaly-score calibration.
Sparse autoencoders in LLM interpretability
In recent mechanistic interpretability work, Sparse Autoencoders (such as TopK and JumpReLU SAEs) are trained on internal LLM activations to decompose polysemantic neurons into thousands of monosemantic, human-interpretable concepts, aiding safety auditing and activation steering.
The over-generalisation risk in anomaly detection
In anomaly detection, an over-parameterised autoencoder can generalise too well and reconstruct anomalous inputs accurately, creating false negatives. Practitioners mitigate this with tighter bottlenecks, denoising objectives, memory-augmented modules and periodic threshold recalibration against concept drift.
Commonly confused terms
| Term | How it differs |
|---|---|
| Principal component analysis (PCA) | PCA finds a linear orthogonal projection maximising variance in closed form, whereas a nonlinear autoencoder with deep neural layers can learn curved manifolds; a single-layer linear autoencoder spans the same subspace as PCA. |
Why an autoencoder matters for on-premises AI
The most common in-house use is anomaly detection: an autoencoder trained only on normal data rebuilds unusual examples poorly and high error flags them. Needing no labelled fraud or fault examples, it suits catching rare events. Autoencoders also serve dimensionality reduction and denoising; sparse autoencoders now feature in work interpreting the internal representations of language models.
A bank trains an autoencoder only on ordinary transaction records and sends transactions whose reconstruction error exceeds a set threshold to in-house analysts for fraud review.
Common questions
Can an autoencoder generate new samples?
A standard autoencoder is not designed for it; its latent space is irregular, so random points do not decode into meaningful samples. Probabilistic types such as the variational autoencoder are used for generation.
How is an autoencoder used for anomaly detection?
It is trained only on normal data. It rebuilds normal examples well; error rises on unusual ones and that high error signals an anomaly.
Related terms
- Variational autoencoder
- Latent space
- Anomaly detection
- Sparse autoencoder
- Representation learning
- Encoder-decoder architecture
Sources
- Hinton and Salakhutdinov, Reducing the Dimensionality of Data with Neural Networks, 2006
- Goodfellow, Bengio and Courville, Deep Learning, 2016
In the glossary: Glossary, A to C