Skip to main content

Loading the visual lab…

#cnn-filtersNeural 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

  1. Welcome to #cnn-filters. On the left, a 10×10 image: 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.
  2. 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.
  3. 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.
  4. Type /all to compute the rest of the windows in one shot. With the vertical-edge filter on the edge image, the map "lights up" exactly on the left/right boundary and stays at zero everywhere else: this filter only sees vertical transitions.
  5. 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.
  6. 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.
  7. Last setting: /stride 2, then /all. The window jumps two pixels each step and the output shrinks from 8×8 to 4×4. This is how (or with pooling) a CNN progressively shrinks its maps to summarize the image.
  8. Your turn: /filter horizontal-edge on the cross (the exact opposite of the vertical filter), /filter sharpen, /image circle, /filter sobel-x, /relu, /slide step 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

  • /slideAdvances the filter by one window and details the multiply-add computation.
  • /allComputes 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.
  • /reluToggles ReLU on the output (clips negatives to 0).
  • /resetBack 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

  • #neuronLet us break a neuron apart: inputs, weights, sum, activation.
  • #dropoutDropout regularization: the best friend of deep networks.
  • #activationWhy an activation? ReLU, sigmoid, tanh, Leaky ReLU, GELU and the vanishing gradient.
  • #gradient-descentLoss is a landscape. The gradient says which way is up, so we step the other way.
  • #backpropagationThe computation graph replayed backwards: each node receives ∂L/∂(itself) and the chain rule does the rest.
  • #overfittingA big model on few data points: the decision boundary twists until it memorizes the noise.
  • #cnn-filtersAn image is a grid of numbers. A 3×3 filter slides over it, multiplies, adds up: that is a convolution.
  • #is-it-einsteinIs 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-3dA word becomes a vector: close in space = close in meaning, and you can do math on them.