In plain words
An autoencoder has two halves. The first half, the encoder, takes something big, like a photo, and squeezes it into a handful of numbers. The second half, the decoder, takes those few numbers and tries to rebuild the photo.
Training is simple: show it lots of examples and reward it when the rebuilt version looks like the original. No one has to label anything. The data is its own answer key.
The key is the squeeze. The code in the middle is too small to store every pixel, so the network has to learn what really matters: the shape, the pose, the overall look. It throws away the rest.
That learned code turns out to be very useful. It can shrink data, clean up noisy images, spot unusual items that rebuild badly, and in a newer form, help generate brand-new pictures. Image generators like Stable Diffusion work inside an autoencoder's compact code.
Everyday example
Describing a face over the phone
You call a sketch artist and describe a friend in just five phrases: round face, curly hair, thick eyebrows, big smile, small nose. The artist draws from those words alone. You are the encoder, the five phrases are the code, and the artist is the decoder. With practice you learn which few details matter most for a good likeness.
Where the example breaks: Your five phrases are words anyone can read. An autoencoder's code is a list of numbers nobody chose, and what each number stands for is often hard for people to interpret.
How it actually works
Formally, an encoder network maps an input to a lower-dimensional code in a latent space, and a decoder maps it back. Both are trained together to minimise the reconstruction error.
The bottleneck
If the code were as big as the input, the network could simply copy it through and learn nothing. A narrow middle layer forces compression. Other designs keep a bigger code but add rules, such as allowing only a few active numbers at once (sparse autoencoders).
Learning without labels
The target output is the input itself, so autoencoders are a classic form of unsupervised learning. They are trained with backpropagation and gradient descent like any other network.
Variants with a job
A denoising autoencoder is fed corrupted inputs and learns to output the clean version. For spotting anomalies, an autoencoder trained only on normal data rebuilds odd items badly, and a large reconstruction error raises a flag.
Variational autoencoders
In 2013 Diederik Kingma and Max Welling described the variational autoencoder (VAE). It encodes each input as a small region of possibilities rather than one point, which makes the code space smooth enough to sample new, realistic outputs from it.
Inside image generators
Latent diffusion models, the 2021 approach behind Stable Diffusion, first use a pretrained autoencoder to shrink images into a compact code. The diffusion model does its work there, which cuts the computing needed, and the decoder turns the result back into pixels.
- Two parts
- Encoder (squeezes input to a code) and decoder (rebuilds input from the code)
- Early roots
- Linked to principal component analysis in the 1980s; Kramer's "nonlinear PCA" in 1991
- Deep breakthrough
- Hinton and Salakhutdinov, 2006: deep autoencoders with 30-number codes rebuilt images better than PCA
- Used for
- Compression, denoising, anomaly detection, image generation, and early face-swap deepfakes
Questions people ask
What is an autoencoder used for?
Shrinking data into compact features for other models, removing noise from images, spotting anomalies that rebuild poorly, and generating new data. Modern image generators such as Stable Diffusion use one to work in a compressed space.
Is an autoencoder supervised or unsupervised?
Usually called unsupervised, or self-supervised, because no human labels are needed: the input itself is the target. The network is still trained with a clear error signal, the difference between input and rebuilt output.
What is the difference between an autoencoder and a variational autoencoder?
A plain autoencoder maps each input to one exact point in its code space, which is good for compression. A variational autoencoder maps each input to a small cloud of likely points, which makes the space smooth so you can sample from it and generate new examples.
Is an autoencoder the same as compression like ZIP?
No. ZIP is lossless and works on any file. An autoencoder is lossy and learned: it only compresses well the kind of data it was trained on, and the rebuilt version is close to, not identical to, the original.
How are autoencoders used in deepfakes?
Early face-swap tools trained an encoder shared across two people and a separate decoder for each face. Encoding person A and decoding with person B's decoder produced B's face with A's expression. See deepfake.
Was this clear?
1 is confusing, 5 is crystal clear. One tap, no account needed.
Spotted something wrong, or know a better example? Suggest a change