#cnn-filters — Neural networks
An image is a grid of numbers. A 3×3 filter slides over it, multiplies, adds up: that is a convolution.
What you'll play with
- Welcome to #cnn-filters. On the left, a
10×10image: each cube is a pixel, its height is its value (0 = dark and flat, 1 = bright and tall). To the computer, an image is nothing but a grid of numbers. Above it floats a 3×3 filter: nine numbers, nothing more. We're going to slide it over the image, multiply pixel by coefficient, then add it all up: that is a convolution. - Place the filter on the first window: type
/slide. The tutor walks through the nine pixel × coefficient products and their sum. That single number becomes the first cube of the output map, on the right. - Again,
/slide. The window has shifted one pixel to the right (stride 1)… but the filter has not changed: the same nine numbers serve every position. That is weight sharing, the great economy of convolutional networks. - Type
/allto compute the rest of the windows in one shot. With thevertical-edgefilter on theedgeimage, the map "lights up" exactly on the left/right boundary and stays at zero everywhere else: this filter only sees vertical transitions. - Change image:
/image cross, then relaunch/all. Only the vertical stroke responds — via its two edges, one positive and one negative — while the horizontal stroke stays invisible to this filter. A horizontal-edge filter would see the exact opposite: you'll try it at the end. - Switch to blur:
/filter blur, then/all. Each output becomes the average of its nine neighbours: strokes spread and soften. The sharpen filter does the opposite: the center is amplified (×5), its neighbours subtracted, contours pop out. We wrote these nine numbers by hand. A CNN learns them by backpropagation, to detect whatever helps its task. - Last setting:
/stride 2, then/all. The window jumps two pixels each step and the output shrinks from8×8to4×4. This is how (or with pooling) a CNN progressively shrinks its maps to summarize the image. - Your turn:
/filter horizontal-edgeon the cross (the exact opposite of the vertical filter),/filter sharpen,/image circle,/filter sobel-x,/relu,/slidestep by step,/reset. A CNN stacks these layers: the first detects edges, the next combines edges into corners, then into shapes, then into objects. The vectors they produce, you'll see them floating in #embeddings-3d.
Channel commands
/slide— Advances the filter by one window and details the multiply-add computation./all— Computes the whole output map at once and interprets it./filter <vertical-edge|horizontal-edge|sobel-x|sobel-y|blur|sharpen|identity>— Changes the 3×3 filter and clears the map./image <cross|diagonal|circle|checkerboard|edge>— Changes the input image and clears the map./stride <1|2>— Window step size: 1 → 8×8 output, 2 → 4×4 output./relu— Toggles ReLU on the output (clips negatives to 0)./reset— Back to the initial state: edge image, vertical-edge filter, stride 1, no ReLU.
Glossary
- Convolution
- Operation that slides a small kernel over the image and computes, at every position, the weighted sum of the pixels covered. The result is a new image: the feature map.
- Kernel
- The small grid of weights (3×3, 5×5…) sliding across the image. In a CNN these weights are learned; here we set them by hand to build intuition.
- Feature map
- Output of a convolution: an image where each pixel says "how strongly the kernel's pattern is present here". A CNN produces dozens per layer.
- Edge detection
- A kernel with positive coefficients on one side and negative on the other responds strongly wherever intensity changes sharply: it "sees" edges.
- Sobel filter
- Classic edge-detection kernel that combines a derivative in one direction with smoothing in the other. Sobel-x finds vertical edges, Sobel-y horizontal ones.
- Stride
- How many pixels the kernel moves at each step. A stride of 2 halves the output size.
- Padding
- Border of zeros added around the image so that the output keeps the same size and the borders are handled like the center.
- Receptive field
- The region of the input image that influences a given pixel of a map. It grows with depth: high-level layers see whole objects.
- Weight sharing
- The same kernel is applied everywhere in the image: few parameters and translation invariance — an edge is an edge, wherever it is.
Other channels in Neural networks
- #neuron — Let us break a neuron apart: inputs, weights, sum, activation.
- #dropout — Dropout regularization: the best friend of deep networks.
- #activation — Why an activation? ReLU, sigmoid, tanh, Leaky ReLU, GELU and the vanishing gradient.
- #gradient-descent — Loss is a landscape. The gradient says which way is up, so we step the other way.
- #backpropagation — The computation graph replayed backwards: each node receives ∂L/∂(itself) and the chain rule does the rest.
- #overfitting — A big model on few data points: the decision boundary twists until it memorizes the noise.
- #cnn-filters — An image is a grid of numbers. A 3×3 filter slides over it, multiplies, adds up: that is a convolution.
- #is-it-einstein — Is it Einstein? Two faces go through the scanner of a network that learned only Einstein: Haythem → NO, Einstein → YES. Watching is free; touching is Premium.
- #embeddings-3d — A word becomes a vector: close in space = close in meaning, and you can do math on them.