TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

What Convolutional Neural Networks Learn: Filters, Receptive Fields, Backpropagation, and LeNet & AlexNet

Status: Draft (2026-10-13), partially measured. The examples were run directly on a laptop CPU (Python 3.9, numpy 2.0). The code is in this folder's code/01_conv.py and finishes in a few seconds. Paper metrics were transcribed from the original texts along with their conditions. Writing rules: Measured data is the default, and unmeasured values are marked as "Unmeasured".

Table of Contents

1. Why Images Need a Special Structure

A single mobile phone photo contains millions of numbers (pixels). Feeding this into a regular neural network, namely a fully connected layer(where every input connects to every output), causes the number of connections to explode. Consider just a single layer that transforms a 32×32 grayscale image into six 28×28 feature maps:

Method Numbers to Learn (Weights)
Fully connected layer 4,821,600
Six 5×5 convolution filters 156

(Direct calculation, code/01_conv.py [5]. Convolution is 6 filters × (25 + 1 bias).)

The 30,000-fold difference is due to two properties inherent in images:

  1. Pixels close to each other are deeply related (Locality). Pixels on the opposite corner are unnecessary for recognizing the outline of a ball.
  2. The same pattern is the same pattern no matter where it appears (Translation invariance). A ball on the left side of the screen and one on the right can be found using the same method.

Convolution is an operation built by baking these two assumptions into its structure. It looks only through a small window (locality) and reuses the same filter across the entire image (weight sharing). This practice of "building assumptions into the structure" is called inductive bias, and in Part 7 we will see what price the Vision Transformer pays by discarding this.

2. Convolution: Sliding a Small Window to Multiply and Add

합성곱: 3×3 창을 밀며 곱하고 더하기 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 입력 6×6 필터(학습) -1 0 1 -2 0 2 -1 0 1 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 출력 4×4 경계에서만 크다 창 9칸 × 필터 9칸을 곱해 모두 더하면 출력 한 칸 층을 쌓으면 한 칸이 보는 범위(수용 영역)가 넓어진다 3×3 한 층 3px 두 층 5px + 풀링(보폭 2) 6px 3×3 세 층 더 18px
Figure: A 3×3 window sliding across the input, multiplying and adding with the filter, showing how the receptive field of a single unit expands as layers stack.

The calculation is simple. Overlapping a 3×3 filter (9 numbers) with a 3×3 window of the image, multiplying corresponding positions, and summing them all up yields a single output unit. Repeating this while shifting the window one step at a time completes the output map.

# code/01_conv.py 에서
def conv2d(x, k):
    kh, kw = k.shape
    out = np.empty((x.shape[0] - kh + 1, x.shape[1] - kw + 1))
    for i in range(out.shape[0]):
        for j in range(out.shape[1]):
            out[i, j] = np.sum(x[i:i + kh, j:j + kw] * k)
    return out

Applying a vertical edge filter (Sobel filter) to a 6×6 image where the left half is 0 (dark) and the right half is 1 (bright) yields the following (measured):

필터            출력(4×4)
[-1  0  1]      [0 4 4 0]
[-2  0  2]      [0 4 4 0]
[-1  0  1]      [0 4 4 0]
                [0 4 4 0]

4 appears only at the boundary where brightness changes, and 0 elsewhere. A filter is a question asking, "Does this pattern exist here?", and the output map spreads the answer to that question across the entire image. Real networks place dozens to hundreds of such filters in a single layer, with each filter searching for a different pattern (horizontal edges, diagonals, color blobs, etc.).

Additionally, what deep learning frameworks call "convolution" is actually cross-correlation, which does not flip the filter unlike the convolution found in math textbooks. Because filters are learned anyway, whether they are flipped makes no difference.

3. Filters Are Not Hand-Crafted: Loss, Backpropagation, Gradient Descent

In traditional computer vision, humans designed filters like the Sobel filter above. The core of CNNs is that filter numbers are learned from data. The learning process has three steps:

  1. Loss function: Measures how much the output produced by the current filter differs from the target answer using a single number. Here, we use Mean Squared Error (MSE).
  2. Backpropagation: Calculates how much the loss changes (the gradient) if each of the 9 filter numbers is slightly altered. In convolution, convolving the "output error" and the "input" yields the filter gradients.
  3. Gradient descent: Slightly shifts the filter in the opposite direction of the gradient. k ← k − 학습률 × 기울기.
# code/01_conv.py 에서 — 필터 k 의 기울기
for x, y in zip(X, Y):
    err = conv2d(x, k) - y                       # 출력 오차
    for a in range(3):
        for b in range(3):
            g[a, b] += np.mean(2 * err * x[a:a + err.shape[0], b:b + err.shape[1]])
k -= lr * g

Try It Yourself: From a Random Filter to a Sobel Filter

We passed 32 random images through a Sobel filter to create "target outputs" and performed gradient descent starting from a random filter (mean 0, standard deviation 0.1) with a learning rate of 0.1 without revealing the target filter (measured, laptop CPU approx. 6 seconds).

Step Loss (MSE)
0 1.064
10 0.730
50 0.193
100 0.037
200 0.0013
500 0.000000

The filter learned after 500 steps was [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]] , and the maximum difference from the target was 0.0005. Even though no human instructed it to "find vertical edges," the data demanded such a filter, causing it to take that shape. This is why plotting the first-layer filters of a real CNN reveals edge and color pattern shapes.

To verify that the gradients computed via backpropagation are correct, we compared them against numerical differentiation(a method of directly measuring loss changes by tweaking a single number ever so slightly). They matched with a maximum relative difference of 6.4×10⁻¹¹. This is always a worthwhile check before trusting self-written training code.

4. Pooling and Receptive Fields: The Scope of a Single Unit

A single output unit of a convolutional layer looks at only a 3×3 patch of the input. To recognize an entire ball or an athlete's arm, we need a wider view. There are two ways to achieve this:

The range of the input that affects a single output unit is called the receptive field. It is calculated per layer as r ← r + (커널 − 1) × j, j ← j × 보폭 (wherej is the cumulative stride). Calculated using the architectures of LeNet-5 and AlexNet (direct calculation, code/01_conv.py [4]).

Network Receptive Field (px) Through Layers Final
LeNet-5 5 → 6 → 14 → 16 → 32 Entire 32×32 input
AlexNet 11 → 19 → 51 → 67 → 99 → 131 → 163 → 195 Most of the 224×224 input

Pooling comes at a cost. Reducing resolution causes the model to lose exact locations. While this poses no problem for classification ("Is there a cat in this image?"), it is fatal for tasks requiring pixel-level ball coordinates. Part 3 (U-Net & HRNet) tackles this exact problem.

5. LeNet-5 (1998): The Prototype of Convolution + Pooling + Backpropagation

LeCun et al.'s 1998 paper introduced LeNet-5 for reading handwritten digits (MNIST). The input is a 32×32 grayscale image. Although the digits in the data are at most 20×20 and centered within a 28×28 grid, the input was intentionally made larger than that (which aligns with the receptive field calculation where the final layer views the entire 32×32 input).

This paper demonstrated that features do not need to be hand-crafted, but can be learned end-to-end using convolutional structures and backpropagation. However, the computational power and data available in 1998 struggled to scale beyond small, clean images like handwritten digits.

6. AlexNet (2012): Same Idea, Different Scale

Fourteen years later, AlexNet by Krizhevsky, Sutskever, and Hinton won the ImageNet competition (ILSVRC, 1000 classes, approx. 1.2 million training images) by a wide margin. The architectural idea is the same as LeNet's. What changed were the scale and several training techniques.

Item AlexNet (Paper)
Scale 60 million parameters, 650,000 neurons, 5 convolutional layers + 3 fully connected layers
Input 224×224×3
Training Split the network across two desktop GPUs (3GB memory each) for 5–6 days, passing 1.2 million images about 90 times
ILSVRC-2012 test top-5 error 15.3%(7 CNN ensemble) vs. 2nd place 26.2%. A single model achieved 18.2% on the validation set
ILSVRC-2010 test top-1 37.5%, top-5 17.0% (average of 10 crops during testing)

"Top-5 error" is the rate at which the correct answer is not among the top 5 choices selected by the model. The fact that 15.3% is an ensemble metric is a condition frequently omitted.

Looking at what the authors directly measured to see what made a difference reveals "why it was designed this way."

In summary, the lesson of AlexNet is not a "single new idea," but a combination of large data + fast computation + techniques that make large networks trainable. Most vision models of the subsequent decade are built upon this formula.

7. Limitations

8. Connection to Our Project

The ball detection models of TT Score (WASB and BlurBall) will still be convolutional neural networksin 2026. The reason is precisely what was covered in this post.

Detailed architectures and measurements can be found in TT Score Model Anatomy Part 2: Ball Detection. The next post covers residual connections and batch normalization, which made deep networks trainable.

TT's Word. We never told the filters "find vertical edges," yet after 500 steps, they turned into Sobel filters. The filters automatically transform into the shapes desired by the data.

References

Sign in to like

Comments

No comments yet.

Sign in to leave a comment