Train a network to copy its input to its output through a narrow bottleneck, forcing it to learn the data's essential structure.
An autoencoder is a neural network trained to do something that sounds pointless: copy its input to its output. The catch is the middle. The encoder squeezes the input down into a small latent code; the decoder rebuilds the input from that code alone. Because the code is far smaller than the input, the network can't just memorize — it has to learn what's *essential*.
x down to a compact latent code z (the bottleneck).z back out to a reconstruction x̂, aiming to match the original x.z = encoder(x) # compress: e.g. 784 numbers -> 32
x_hat = decoder(z) # rebuild back to 784
# reconstruction error — the only thing we train on
loss = mean((x - x_hat) ** 2) # MSE; no labels neededx is just x. There's no human annotation — the network learns features purely by being forced to reconstruct data through a bottleneck. Whatever survives the squeeze is the data's structure.Feed a corrupted image in (add random noise) but score the reconstruction against the clean original. To minimize error the network must learn to throw the noise away and keep the underlying digit, edge, or shape. The result is a denoising autoencoder — the same copy-through-a-keyhole idea, now cleaning data as a side effect.