Autoencoder
An autoencoder is a self-supervised neural network made of an encoder that compresses inputs into a lower-dimensional latent bottleneck and a decoder that reconstructs the original input from that representation. Because the input itself acts as the training target, this self-supervised paradigm also underpins masked representation learning and contrastive multimodal pretraining.

From Prof. Tom Yeh’s Walkthrough

The autoencoder is a foundational self-supervised learning architecture for training models on massive unlabeled datasets—spanning billions of web-scale examples.
At that scale, hiring humans to manually label every training target is infeasible. Instead, self-supervised methods derive training targets directly from the data itself (automatically, from the Greek auto, meaning “self”):
- Reconstruction (Autoencoders): Use the full input example itself as the target to reconstruct through a compressed bottleneck.
- Masking (Masked Modeling): Hide parts of the input and predict the missing pieces from the surrounding context—the core objective behind encoder models like BERT (Masked Language Modeling) and Masked Autoencoders (MAE). (Note: modern autoregressive LLMs likewise derive targets automatically from unlabeled text via causal next-token prediction rather than masked reconstruction.)
- Contrastive Pairing: Pair aligned modalities (such as images and text) so each acts as the matching target for the other. This contrastive learning objective powers dual-encoder models like OpenAI’s CLIP and underpins many multimodal foundation models.
Network Architecture
Encoder
Linear(4, 3)ReLULinear(3, 2)ReLU
Decoder
Linear(2, 3)ReLULinear(3, 4)
Step-by-Step Walkthrough
[1] Given
- Four training examples , each represented as a 4-dimensional input vector.
[2] Auto (Self-Target)
- Copy the input training examples to serve as the reconstruction targets ().
- Because each target is the input itself, the network learns compressed features without external labels.
[3] Encoder: Layer 1 + ReLU
- Multiply the 4-D inputs by the learned weight matrix and add biases to project into 3 dimensions.
- Apply , zeroing out negative activations (e.g., ).
[4] Encoder: Layer 2 + ReLU (Bottleneck)
- Multiply the 3-D hidden features by the second layer’s weights and biases, then apply ReLU.
- This layer is the bottleneck because its latent output has fewer dimensions () than the original input (), forcing the encoder to retain only the most salient structure.
[5] Decoder: Layer 1 + ReLU
- Project the 2-D latent codes back up to 3 dimensions with learned weights and biases, followed by ReLU (in the example diagram, all activations at this step are non-negative so none are zeroed).
[6] Decoder: Layer 2 (Reconstruction Output)
- Apply the final linear layer (
Linear(3, 4)) without ReLU so the reconstructed output can take arbitrary real values matching the input space.
[7] Loss Gradients & Backpropagation
- Compute the reconstruction error between outputs and targets .
- Hand-calculation exercises typically use Sum of Squared Errors (keeping arithmetic clean), while training code averages over elements with Mean Squared Error:
- Subtract targets from outputs () and scale by (or ); these gradients then propagate backward through both the decoder and encoder to update all weights and biases.