To a computer, a photo is a grid packed with numbers. Both hand-crafted features and a neural network that lays the pixels out in a single line (MLP) are easily thrown off by this grid. We follow what the convolutional neural network (CNN), which slides one small filter across the grid, solved and what it still has not, computing each number ourselves.
If you zoom far into a picture on a screen, you see small squares (pixels). One pixel is one number for brightness — or, in color, three numbers for red, green and blue.
A number grid is usually stored as integers from 0 (black) to 255 (white). When feeding it to a neural network, it is often divided by 255 to get values from 0 to 1. The calculations on this page also use 0–1. One phone photo (e.g. 4000×3000 color) holds 36 million numbers. The fact that the number grid is this large is the starting point for the following sections.
We need to tell three shapes (+, ×, ○) apart. A person chose two clues: "Is the center filled?" and "Are the horizontal/vertical strokes darker than the diagonal strokes?" The machine only learns the weights for these two numbers.
The features in this example were made simple on purpose. Real researchers spent years designing far more elaborate features, such as counting edge directions region by region. Even so, objects in photos vary endlessly in position, size, lighting and angle, and it was hard for people to foresee every change and build it into features. The tide turned at the 2012 ImageNet competition, which classifies photos into 1,000 categories: a CNN that learns even the features by itself reached a top-5 error of 15.3%, far ahead of the runner-up (26.2%) [R4].
To feed a photo to the MLP (multilayer perceptron) from 3-2, the grid must be unrolled into one line. Let's look one by one at the problems that appear the moment it is unrolled.
Local connections · weight sharing · pooling · stacking layersFukushima 1980 → LeCun 1998
| MLP's problem | CNN's answer | How far it solves it |
|---|---|---|
| ① Loss of neighbor relations | Local connections: one neuron looks only at a small neighborhood patch such as 3×3 | Looking at neighboring pixels together is built into the structure |
| ② Weight explosion | Weight sharing: the same filter is used at every position | Number of filters × 9 is enough, regardless of photo size |
| ③ Position changes | Weight sharing + pooling: the same filter finds the pattern wherever it is, and pooling absorbs small shifts | Relatively less shaken. Not perfect: accuracy drops when the picture is shifted a lot (Section 8) [R6] |
| ④ Pixel order ignored | Stacking layers: group nearby pixels to build up wider and wider shapes | In return, it relies on the assumption that "nearby pixels are related." Shuffling the pixels lowers performance (Section 8) |
In the cat visual cortex, Hubel and Wiesel distinguished "simple cells," which respond to a bar of a particular orientation in a narrow region, from "complex cells," which respond to the same orientation even if the position differs slightly [R1]. Fukushima's Neocognitron imitated these two cell types by alternately stacking "feature-finding layers" and "position-blurring layers" [R2]. Today's CNN convolution and pooling layers are their descendants. However, the Neocognitron learned by a method other than backpropagation; it was LeCun and colleagues who made a backpropagation-trained CNN succeed at handwriting recognition [R3].
Output = Σ (input patch × filter)6×6 input · 3×3 filter → 4×4 output
Place the filter window over one spot of the input. Multiply the 9 overlapping cells pairwise and add them all; that sum becomes one output cell. Move the window one cell at a time and repeat. On a 6×6 input, a 3×3 window fits in 4 positions across and 4 down, so the output is 4×4 (without padding, i.e. filling the border with zeros).
The vertical edge filter has +1 in the left column and −1 in the right column. So it gives a positive value where "the left is bright and the right is dark," a negative value in the opposite case, and close to 0 where it is uniform. A neural network learns such filter numbers by backpropagation instead of having people set them. Note also that the "convolution" of deep learning, unlike mathematical convolution, does not flip the filter (cross-correlation). Since the numbers are learned, the result is the same [R8].
Pass the 4×4 output from Section 5 through ReLU (negative → 0), then keep only one number for each 2×2 window (maximum or average). We also see what changes when the picture is shifted by one cell.
Pooling cuts the numbers to a quarter, lightening the next layer's computation, and absorbs small shifts that happen inside a 2×2 window. A shift that crosses a window boundary, or a shift of 2 or more cells, changes the result directly. That is why "relatively less shaken" is more accurate than "CNNs are robust to position changes." In fact, research shows that even well-known large CNNs can change their answer when a picture is shifted by just a few pixels [R6].
Turn the last feature maps into a single line of numbers, then pass them through a fully connected layer and softmax to produce "probability of +, probability of ×, probability of ○." We use the CNN from Section 8, trained in advance, as is.
Classic CNNs such as LeNet joined the last maps together as they were (flattening) and fed them to a fully connected layer [R3]. Because this passes along even "which cell of the map the feature was in," the network becomes sensitive to position again. Global pooling, which keeps only one number per map (the maximum or the average), erases position information, so it is less shaken by shifts and has fewer parameters [R5]. The CNN on this page uses global max pooling.
Softmax turns the 3 scores into 3 probabilities that add up to 1. The larger the score, the larger the probability. A high probability is not always right: on appearances not seen during training, the model can give a high probability even to a wrong answer (3-1 Section 4).
Both train on 120 pictures of 3 kinds of 12×12 shapes (40 each). All training pictures are centered (±0.5 cell) and mixed with noise, stray strokes, rotation and stroke-width changes. Each test uses 150 pictures never seen before.
Both code examples use only libraries preinstalled in Colab. After "Download notebook (.ipynb)", open it in Colab with File → Upload notebook, or copy the code and paste it into a new notebook cell.
Computes convolution → ReLU → max and average pooling with the same 6×6 digit "7" and the same 4 filters as Sections 5·6. The output numbers match the page's numbers cell for cell. To use your own data, change only IMG at the part marked [To use your own data] in the code.
Repeats the experiment in a production library, with the same model structures and the same shape rules as Section 8. The optimizer is changed to Adam (40 epochs), and the run is repeated over 3 seeds and averaged. For pixel shuffling, the models are retrained from scratch on data shuffled with the same rule.
These are prompts to paste into AI assistants such as ChatGPT, Qwen, or Claude. Pressing "Copy" attaches the chosen code after the prompt. Replace the parts in 〔 〕 with your own situation.
An AI's answer is only a starting point. Always check any papers, figures, or library functions it suggests against the original sources and official documentation. If you used AI help for a competition entry or paper, disclose the fact and extent of its use according to the rules of the organizers and the journal.
This is the same dictionary as the yellow dotted underlines in the text. The same terms are used throughout the series. Click a section name to jump to where the term first appears.
Analogies are a first step to understanding, but they can also seed misunderstanding. Fruit fly and brain analogies are marked by strength. Direct evidence that they actually do the same thing · Partial only some properties are similar · None no known counterpart
| Concept | Everyday analogy | Fruit fly / brain analogy | Where the analogy breaks down |
|---|---|---|---|
| Pixel | One mosaic tile | Partial One ommatidium of the fruit fly's compound eye | Ommatidia are arranged in a hexagonal pattern and are sensitive to changes in brightness. A photo's pixels are static values on a square grid |
| Filter | A magnifying glass that reveals only a particular pattern | Partial Orientation-selective cells in the primary visual cortex [R1] | A neuron's receptive field differs slightly from place to place. A CNN filter is exactly the same at every position |
| Weight sharing | Stamping the same stamp all over a sheet of paper | Partial Neurons of the same type in the fruit fly visual system are repeated across the whole visual field | Each neuron in the brain has its own connection strengths. They do not "share" numbers |
| Pooling | Making a reduced copy of a map | Partial Complex cells that respond even when the position differs slightly [R1] | Whether complex cells compute exactly a maximum has not been confirmed |
| Stacking layers | Drawing a picture as dots → lines → shapes | Partial The visual pathway V1 → V2 → V4 → inferior temporal cortex (3-1 Section 5) | The brain has many feedback connections; a CNN flows in one direction only |
| Flatten | Laying the stones of a Go board out in a single line | None | Once laid out in a line, "who is whose neighbor" disappears (Section 3 ①) |
| Softmax | Turning vote counts into vote shares | None | A high vote share does not make an answer correct. On a picture it has never seen, the model can be confidently wrong |
| Shuffle pixels | Mixing up puzzle pieces by a fixed rule | None | People can hardly recognize a shuffled picture, but the MLP learns it just as well. What "seeing like a human" means differs from model to model |
E-1 About the author · E-2 Academic references · E-3 Figure sources
The following materials served as references for structure and content.
A guide for instructors, on-the-job (OJT) trainers, and tutors. Times are estimates; adjust them to your actual class.
| Audience | University students and working professionals who have finished 3-2. Practitioners who handle image data (inspection images, medical images, document scans) |
|---|---|
| Prerequisites | The hidden layer and backpropagation concepts from 3-2. Multiplication and addition alone are enough to follow the calculations in Sections 5·6 |
| Learning objectives | ① Explain that a photo is a grid of numbers and give four reasons an MLP gets stuck ② Compute convolution, ReLU and pooling by hand ③ Use experimental results to explain that a CNN is "relatively less shaken by position changes, but not perfectly" |
| Estimated time | Reading 40–50 min · animation demos 25 min · Colab practice 30 min (Code 1: 10 min, Code 2: 20 min) |
Intro 5 min (the numbers of the Section 1 color fruit fly) → Section 3, the four reasons, 10 min → Sections 5·6 hand calculation 15 min → Section 8 dashboard 15 min → Check questions 5 min.
Section 3 ② weight explosion, calculated with your company's image size, 10 min → Section 8 20 min (what if the on-site camera position changes?) → Code 2 hands-on 30 min → discussion "What augmentation does our data need?" 20 min → prompt cards 10 min.
Beginners: Sections 1·3·5·8 only. Intermediate learners: have them compute one output cell of Section 5 by hand and compare it with the conv2d function in Code 1, then count the parameters of flattening vs. global pooling themselves in Section 7.
| Section | Questions to pause and ask | Hands-on tips |
|---|---|---|
| 1 Number grid | "What numbers is the red of the fruit fly's eye in the three channels?" | On the color fruit fly, press the Red, Green and Blue views in turn |
| 2 Classic ML | "Why do hand-crafted features collapse on shifted pictures?" | Press Clean picture → Shifted 2 cells in order and compare the accuracy bars |
| 3 MLP limits | "How many positions apart in the line is the pixel directly below?" | In ② Weight explosion, press 1000×1000 so learners are surprised by the size of the number |
| 4 CNN's answer | "Why does sharing a filter make the number of weights independent of photo size?" | In Stacking layers, point out how the range one neuron sees widens 3 → 4 → 8 |
| 5 Convolution | "Why is the output at this spot negative?" | Pause and read the formula together using "Step one cell" |
| 6 ReLU · pooling | "After a one-cell shift, which changes less: before or after pooling?" | Alternate between the original picture and the picture shifted by 1 cell |
| 7 To probabilities | "Which is less sensitive to position: flattening or global pooling?" | Choose "+ shifted 2 cells," then switch between the two methods |
| 8 Dashboard | "Who wins on centered pictures, and who wins on shifted pictures?" | Look at Shift position first, then switch to Shuffle pixels and see the result flip |
| Misconception | Correct explanation | Scene to show |
|---|---|---|
| A CNN recognizes things equally well even when their position changes | It is only relatively less shaken. Accuracy drops when the picture is shifted a lot, and even large CNNs can change their answer after a shift of a few pixels | Section 8 Shift position, Section 6 |
| A CNN is always more accurate than an MLP | When pictures are always in the same place, as on this page, the MLP can even score higher. A CNN's strengths are parameter efficiency and robustness to shifts | Section 8 accuracy at 0 cells |
| Filters are set by people | The filters in Section 5 are for explanation. A real CNN learns its filter numbers by backpropagation | The learned maps in Section 7 |
| Pooling adds information | Pooling reduces the numbers and discards information. In exchange, it absorbs small shifts and cuts computation | Section 6, 4×4 → 2×2 |
| A CNN is the same as the brain's visual cortex | It was inspired by simple and complex cells, but its learning method and connection structure differ | The "Partial" labels in common Section D |
224 × 224 × 3 = 150,528 inputs × 1,000 = 150,528,000 (about 150 million). A convolution layer with 64 3×3 color filters has 3 × 3 × 3 × 64 = 1,728 (1,792 including biases).
(6 − 3 + 1) × (6 − 3 + 1) = 4×4.
The second row of the overlapping patch is [0, 3, 3], and each row of the filter is [1, 0, −1]. 0×1 + 3×0 + 3×(−1) = −3. The first and third rows are all 0, so the total is still −3.
Max 6, average (6 + 3 + 0 + 3) / 4 = 3.
The CNN. The CNN builds the assumption that "nearby pixels are related" into its structure (3×3 filters, pooling), but after shuffling, nearby cells become unrelated pixels. The MLP never used the positional relations between pixels in the first place, so shuffling leaves it almost unchanged. The key condition is that the models are trained from scratch on shuffled data, not that shuffled pictures are fed to an already-trained model.
Add one diagonal edge filter to FILTERS in Code 1, find which cell of the 6×6 "7" responds most strongly, and explain why in two sentences.
Mix pictures shifted by 1–2 cells into the training data of Code 2 (data augmentation). Summarize in a table how both models' accuracy at 0–3 cells changes, and compare "robustness gained from structure" with "robustness gained from data."
| Beginners | Sections 2 and 7 can be skipped without breaking the flow. For Section 8, read only the result bars together |
|---|---|
| Advanced | Have learners turn the receptive-field calculation in Section 4 Stacking layers (3 → 4 → 8) into a general formula. Discuss the limits in Section 6 together with the tables in the [R6] paper |
| Further learning | Sangsun Ahn, “Data Science for Business” lecture notes (data science in general) · STEP [K-Digital] AI Natural Language Processing (linked to 3-5 and 3-8) · STEP [K-Digital] Fundamentals of Fintech Data Analysis (linked to 3-6) |
| Materials for instructors | Grading criteria for the check questions and sample answers for the assignments are on the Answer key for educators page (3-3) |
You've read "3-3 Images and CNNs" all the way through. Everyone at the lab will sum it up with a word each.