Chapter 3
Stride, padding and dilation.
The kernel's weights decide what a convolution looks for. Three other settings decide where it looks, and how big the output comes out.
A convolution slides a small grid of numbers across an image. This chapter is about three settings that control that slide: how far it jumps each step, what happens at the image’s edges, and how spread out the grid is. Each one changes the size of the output. Getting that size right is most of the bookkeeping in designing a CNN, so the chapter takes the settings one module at a time and then puts them together into a single formula.
Quick recap
Chapter 2 covers these ideas in depth. Until it’s written, here is everything this chapter relies on.
- Image. A grid of numbers, one per pixel. In this book, 0 is black and 1 is white, and pixels are numbered from 0, starting at the top-left.
- Kernel. A small grid of numbers that slides over the image. This chapter uses 3×3 kernels.
- Weights. The numbers inside the kernel. A 3×3 kernel has nine weights.
- Tap. One square of the kernel, the spot where a weight sits over a pixel. A 3×3 kernel has nine taps, so it reads nine pixels at a time.
- Output. One number computed from one kernel position. Multiply each weight by the pixel under its tap, then add up the nine products. This multiply-then-add is called a dot product: pair up two lists of numbers, multiply each pair, and sum.
- Convolution. Sliding the kernel across the image and computing an output at every position it stops. The outputs, laid out in the same order as the positions, form a new grid called the output map.
The figures in this chapter use a blur kernel, a kernel whose nine weights are all 1/9. Its dot product adds nine pixels and divides by nine, so each output is the average of the nine pixels under the kernel. That makes the output map easy to read, because it’s just a softer copy of the input. Only the setting being discussed changes from figure to figure.
Modules
Each module ends in a short knowledge check. Passing it unlocks the next module. Your progress is saved in this browser.