Encoder, Bottleneck & Decoder
Squeeze data through a latent space.
Encoder, Bottleneck & Decoder is a free Deep Learning Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Deep Learning Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Meet the Autoencoder
An autoencoder learns to copy its input to its output. The trick is forcing the data through a tiny middle, so it must learn what truly matters.
The Encoder Compresses
The encoder takes your input and squeezes it down into a small set of numbers. Think of it as packing a suitcase: only the essentials fit.
The Bottleneck
The bottleneck is the smallest layer in the middle. Its tiny size is the whole point: the network cannot just memorize, it has to summarize. 🎯
The Latent Code
The compressed numbers in the bottleneck form the latent code. This short vector is a dense, learned summary of your original input.
The Decoder Rebuilds
The decoder takes the latent code and tries to rebuild the full original input. It unpacks the suitcase back into something useful.
Reconstruction Loss
You measure success with reconstruction loss: how close the output is to the input. Lower loss means a better rebuild.
loss = mse_loss(decoded, original)An Encoder in PyTorch
An encoder is often just stacked linear layers shrinking the size. Here input 784 becomes a latent code of just 32 numbers.
encoder = nn.Sequential(
nn.Linear(784, 128), nn.ReLU(),
nn.Linear(128, 32))A Mirror-Image Decoder
The decoder usually mirrors the encoder, growing the code back to full size. Symmetry keeps the design simple and balanced.
decoder = nn.Sequential(
nn.Linear(32, 128), nn.ReLU(),
nn.Linear(128, 784))Why Force Compression?
If the middle were large, the net could just copy values straight through. The narrow bottleneck forces it to find real structure in the data.
Trained Without Labels
Autoencoders learn from data alone, no labels needed. This makes them a classic example of unsupervised learning. ✨
The Latent Space
All possible latent codes together form the latent space. Similar inputs land near each other, giving you a compact, meaningful map of your data.
Quick Check
Let us check the core idea of the bottleneck.
Recap
You met the three parts: an encoder that compresses, a tiny bottleneck holding the latent code, and a decoder that rebuilds. Reconstruction loss guides it all. 🎉
Frequently asked questions
Is the “Encoder, Bottleneck & Decoder” lesson free?
Yes — the full text of “Encoder, Bottleneck & Decoder” is free to read here on the web, and the Deep Learning Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Deep Learning Academy course, upgrade to CoddyKit PRO.
What will I learn in “Encoder, Bottleneck & Decoder”?
Squeeze data through a latent space. You practise Deep Learning Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Deep Learning Academy?
No prior experience is required. Deep Learning Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Encoder, Bottleneck & Decoder” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Deep Learning Academy lesson?
Yes. Every Deep Learning Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Encoder, Bottleneck & Decoder
- Denoising Autoencoders
- Variational Autoencoders & the Latent Space
- Anomaly Detection by Reconstruction Error