6.1 Autoencoders
1. Learn
Section titled “1. Learn”- Goodfellow, Bengio, Courville, Deep Learningchapter 14 Autoencoders: the introduction, 14.1 Undercomplete autoencoders, 14.2.2 Denoising autoencoders and 14.5 Denoising autoencoders
- Understanding Deep Learning (Prince)chapter 14 Unsupervised learning, sections 14.1–14.2: the kinds of unsupervised models and what makes a good generative model
- Hinton and Salakhutdinov, Reducing the Dimensionality of Data with Neural Networks (Science 2006)the whole paper (4 pages); figure 3 compares 2D codes of MNIST from PCA and a deep autoencoder
2. Bridge
Section titled “2. Bridge”Learning without labels. Part 6 is about models that learn the structure of data itself. The simplest is an autoencoder: an encoder maps an image x to a short code z, a decoder maps z back to a reconstruction x̂, and the only loss is how far x̂ is from x (Goodfellow et al., chapter 14). The code is too small to copy the input, so the network has to find what the images have in common.
Linear means PCA. With linear maps and squared error, the best k-number code spans the same subspace as the top k principal components (Goodfellow et al., section 14.1). It finds the subspace, not PCA’s basis: any invertible mixing of the code gives the same reconstructions. The derivation below follows from Eckart–Young (1.2).
Nonlinear means bent. With hidden layers and nonlinearities the code can follow a curved surface through image space. On MNIST a deep autoencoder’s 2D codes separate the digits far better than PCA’s two components, with no labels used (Hinton and Salakhutdinov 2006, figure 3). For pixels in [0, 1] the usual loss is binary cross-entropy on the decoder’s logits: the negative log-likelihood of an independent Bernoulli per pixel (2.4).
Denoising. Corrupt the input, for example by setting a random half of the pixels to zero, and train the network to reconstruct the clean image. It can no longer get away with copying, so it must learn what digits look like (Vincent et al. 2010).
Not yet a generative model. Nothing makes the codes fill the latent space. Between and around the clusters lie codes the decoder never saw in training, and decoding a random code can give a smudge instead of a digit. The variational autoencoder (6.2) fixes this by asking the codes to follow a known distribution that you can sample from (Kingma and Welling 2013).
3. Explore
Section titled “3. Explore”Autoencoders: edit exercises/stubs/m6_1_autoencoders.py on your own machine. This task needs PyTorch, which the in-page runner does not have.
pip install torch # CPU build is enough for the tests
mlc check 6.1Then train on MNIST. Open notebooks/6.1-autoencoders.ipynb on Kaggle (a CPU is enough) and paste in your 6.1 file. It checks your linear autoencoder against PCA, plots your 2D codes next to PCA’s, compares codes of 2, 8 and 32 numbers, trains a denoising autoencoder, and decodes interpolations and random codes.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.