Learning to copy, badly on purpose
- : the encoder, mapping input to a code.
- : the decoder, mapping the code back.
The target is the input itself, so no labels are needed and any pile of data is a training set.
Copying is trivial unless something prevents it. The bottleneck is that constraint: the code is too small to hold the input, so the network must decide what to keep.
What it keeps is the structure that repeats across the dataset, which is exactly what a useful representation is.
The linear case is PCA
With linear layers and squared error, the optimal solution spans the same subspace as the top principal components.
The autoencoder does not recover the components individually, only the subspace, since any rotation inside it gives the same reconstruction.
The whole gain from a deep autoencoder is that the surface it fits can bend, so it captures structure a plane cannot.
The other ways to force a choice
A denoising autoencoder corrupts the input and asks for the clean version, which stops it learning the identity even when the code is large.
A sparse autoencoder penalises active units instead of limiting their number, so the code is wide and only a few entries fire per input.
That variant is what is now used to read features out of language models, where a very wide sparse code separates concepts a dense activation had mixed together.
One training run, in order
- Choose the code size, which is the main decision.
- Encode a batch, decode it, and compute the reconstruction error.
- Backpropagate through both halves at once, since they train jointly.
- Watch the reconstruction on held-out data rather than on the training set.
- Discard the decoder if the representation is the product.
What it is and is not good for
As a codec it loses to purpose-built compression, because it is learned for one distribution and has no rate control.
It is genuinely useful here. Trained on normal data only, it reconstructs normal inputs well and unusual ones badly, and that error is an unsupervised anomaly score.
The plain autoencoder cannot generate.
Its code space has no structure, so a randomly chosen decodes to nothing meaningful, and the regions between two valid codes are undefined.
Fixing that is exactly what the variational autoencoder does, by making the code a distribution rather than a point.