liveBook · Manning

Encoder

As explained in Grokking AI Algorithms, Second Edition

An encoder is a neural-network component that transforms high-resolution input representations into progressively more compact representations of higher-level information.

An encoder turns an input into a representation a model can use. Think of it as a summarizer: it keeps useful information while changing the form or level of detail. What it does depends on the task. A U-Net encoder shrinks image feature maps to capture broader context; a text encoder turns words into numerical embeddings. section 12.15 section 12.11

In a U-Net for image generation, the encoder is the downsampling half. Convolutional layers extract features from a noisy image and progressively reduce their spatial resolution. Deeper features help answer “What am I looking at?” but retain less precise information about where edges and textures belong. The decoder upsamples the representation, while skip connections pass earlier, higher-resolution features to it so it can recover fine detail. section 12.15 section 12.17

Following an 8×8 noisy image

An 8×8 image first meets eight separate 3×3 convolutional filters. Each filter scans the image, combining each local patch with its learned values and a bias. The result is eight 8×8 feature maps, or an 8×8×8 tensor. Group normalization then recenters and rescales groups of feature maps before activation. A later convolution uses a stride of 2 to downsample: with the illustrated 4×4 filter and padding of 1, an 8×8 feature map becomes 4×4. The image is smaller, but the network can work with features rather than individual pixels alone. section 12.17

Figure 12.27 The U-Net architecture
12_27

The U-shaped diagram shows where the shrinking encoder path, bottleneck, expanding decoder path, and detail-preserving skip connections fit together. section 12.15

“Encoder” does not always mean an image-shrinking network. A pretrained text encoder can turn a label such as “a happy face” into an information-rich embedding; a small feed-forward network can then adapt that embedding to guide image denoising. In the simplified Transformer workflow, encoding also names the initial preparation of token and position information for self-attention. That use should not be confused with a classic multilayer Transformer encoder: many modern language models are decoder-only. section 12.11 section 11.11

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Works through image-filter outputs and downsampling calculations, while distinguishing initial Transformer embedding from a classic multilayer encoder.
Examples
Traces an 8×8 noisy image through eight 3×3 filters and uses “a happy face” as a text-embedding example.
What it assumes
Builds on a basic understanding of convolutional neural networks for the U-Net explanation and introduces the encoder as a summarizer.
What you can do after
Evaluate/understand how U-Net downsampling trades precise locations for broader context and why skip connections help reconstruction.
How it connects
Connects convolution, feature maps, downsampling, bottlenecks, decoders, and skip connections in U-Net; also connects text embeddings to denoising guidance.

Also explained in

Compare how 21 books explain encoder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.