liveBook · Manning

Convolutional layer

As explained in Grokking AI Algorithms, Second Edition

A convolutional layer is a neural-network layer that applies shared filters to local regions of an input representation while preserving spatial organization.

A convolutional layer looks for patterns in an image without losing track of where its pixels sit. Unlike a linear feed-forward layer that processes all its inputs together, it examines small regions of the image. Think of each filter as a tiny magnifying glass trained to spot a particular pattern, such as an edge. section 12.13 section 12.14

One calculation under the filter

Imagine a 3×3 filter resting on a patch of an 8×8 grayscale image. Pair each filter weight with the pixel beneath it, multiply each pair, then add the results. For one row, filter values [2, 7, 2] and pixels [11, 2, 1] give (2×11) + (7×2) + (2×1) = 38. The filter slides right and repeats the calculation at the next position. section 12.14

Figure 12.24 How a CNN filter scans an image
12_24

Follow the filter across the image to see how each local patch contributes a value. section 12.14

The values produced by one filter form a feature map. Different filters can learn different patterns; their weights begin randomly and change during training. An image may have one channel for grayscale or three for red, green, and blue. section 12.14

Eight views of a noisy image

In a U-Net encoder, eight distinct 3×3 filters scan an 8×8 noisy image. With padding to retain its dimensions, they produce eight 8×8 feature maps: an 8×8×8 tensor. A NumPy implementation pads the image, loops over filters and positions, multiplies each local patch by its filter, and adds that filter’s bias. section 12.17

Convolution can work alongside pooling to summarize image patterns for recognition. In a U-Net, encoder convolutions help capture broader context as the image is downsampled; a related learnable operation, transposed convolution, enlarges feature maps in the decoder. The practical distinction is direction: a regular convolution reads a patch to produce a value, while a transposed convolution uses a value to contribute to a larger patch. section 9.29 section 12.19

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Works through filter scanning, dot products, feature-map shapes, padding, and NumPy loops; stops short of a complete training procedure.
Examples
Traces a 3×3 filter over an 8×8 image, calculates a row dot product, and produces eight feature maps.
What it assumes
Introduces image grids, channels, filters, and dot products through small examples before showing NumPy code.
What you can do after
Build a feature-map calculation from scratch with NumPy loops, padding, filters, and biases.
How it connects
Links feature maps and U-Net downsampling to transposed convolution and skip connections during upsampling.

Also explained in

Compare how 14 books explain convolutional layer →

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.