Perceptrons for 3×3 Pictures
Dec 2026
Look at these three simple 3×3 pictures—A, B, and C:
If someone asks you, “Is this a vertical line?”, the answer is simple: Yes for A, No for B, No for C.
If you are asked to build a machine that gives the same answers, it gets a bit more complicated. However, since we are getting used to machines giving us answers, it is worth looking closer at the models and ideas behind them.
One of the earliest ideas behind these machines is the perceptron. What is it, and how does it work?
Calculating vs. Recognizing (1943–1958)
Turing’s model and early computers were designed around calculation: feed in numbers, follow a strict if / then recipe step by step, and print out a result. This worked well for numbers, but things got more complicated for machines that had to deal with images.
In 1943, neurophysiologist Warren McCulloch and logician Walter Pitts described a simplified neuron, inspired by biology: it adds up incoming signals and answers yes or no (McCulloch & Pitts, 1943; free scan). A few years later they turned to how we recognize visual forms (Pitts & McCulloch, 1947), and in 1957–1958 psychologist Frank Rosenblatt turned the idea into a machine that could learn to classify images from examples, without being told the rule.
In 1958, digital computers filled entire rooms. By having these limits, Rosenblatt then built his Mark I Perceptron out of literal hardware: a 20×20 grid of 400 light-sensitive photocells acting as a tiny “eye,” patch cords wiring the eye to the rest of the machine, and racks of potentiometers—volume knobs turned by little electric motors every time the machine guessed wrong.
If we shrink Rosenblatt’s 20×20 eye down to a 3×3 grid—just 9 squares (1 for black, 0 for white)—we can still explain some ideas behind today’s neural networks. A 3×3 grid allows only 2⁹ = 512 different pictures. For now, let’s start small and try to detect the vertical line in image A.
1. Building a Perceptron by Hand
Look back at A, B, and C and ask yourself: when you checked whether an image was the middle vertical line, which squares did your eyes inspect?
You checked the three squares down the middle column.
This detector can be built like this: Wire all 9 pixels into a single summing node Σ:
- Give the three middle-column wires a strength of
+1(drawn as thick blue lines). - Leave the other six wires at
0(thin dashed grey lines—dead wires). - Whenever we hold up an image, the masked pixels (
1) add to the sum; white pixels (0) send nothing.
Inside Σ, the signals arriving from all 9 wires add up to one number, the score s. Let’s check what score s arrives for A, B, and C:
- A has all three black pixels on the middle column:
s = 1 + 1 + 1 = 3. - B (middle row) crosses the center square, picking up one blue wire:
s = 0 + 1 + 0 = 1. - C (diagonal) also crosses the center square:
s = 0 + 1 + 0 = 1.
How many hits should Σ require before the machine says Yes to the “is it vertical?” question? One hit isn’t enough, because B and C both get 1. All three middle squares must be black, so we set our cutoff anywhere between 1 and 3—say, 2.5:
So this is already a perceptron. Every technical term maps directly to a part we just used:
- Weights (
w): the 9 wire strengths. Arranged as a 3×3 grid (0 1 0 / 0 1 0 / 0 1 0), the weights form a 3×3 template (mask) laid over the image. - Sum / score (
s): the total signal arriving atΣacross all 9 wires—the single internal state that drives the decision. - Threshold: the cutoff (
2.5) above which the machine says Yes (s > threshold). - Answer (
y): the machine’s output (1for Yes,0for No).
Let’s name our vertical-line machine PVer for Vertical Perceptron. Because we can write down a 3×3 template and threshold that answer the question on A, B, and C, we know this task is representable—a single neuron can express it.
Now comes our next question: what if nobody draws the template for PVer?
2. Can PVer Learn Its Own Template?
Let’s erase our hand-crafted template and set all 9 wires to 0, keeping threshold = 0 (so PVer says Yes only when s > 0).
Right now, PVer is blind: every black pixel hits a 0 wire, so A, B, and C all produce s = 0, and PVer answers No (y = 0) to everything.
To let PVer learn from its mistakes, we need a teacher:
- Target
t: the answer the teacher expects (t = 1for A,t = 0for B and C). An image paired with its targettis called an example. - Error
e = t − y: comparing the teacher’s targettwith the machine’s answeryleaves three possible cases:e = 0(correct):ymatchest.e = +1(too cautious): the machine said No (0), but should have said Yes (1).e = −1(too eager): the machine said Yes (1), but should have said No (0).
Here is PVer before any learning step, judged against the teacher:
Our goal is to adjust the 9 weights so the error e drops to 0 on every example.
How should PVer turn its knobs when it gets an example wrong? White pixels (x = 0) sent nothing into Σ—they weren’t involved in the decision, so their wires stay untouched. Only the black pixels (x = 1) get changed (w ← w + e · x):
- When
e = +1(too cautious), add+1to the wire of every black pixel in that image so the scoresgoes up next time. - When
e = −1(too eager), subtract1from the wire of every black pixel in that image (shown in red once a weight goes below0) so the scoresgoes down next time. - When
e = 0(correct), change nothing.
Note for ML & math readers: In a textbook perceptron, the threshold—usually written with a flipped sign as a learnable bias (
b = −threshold)—is updated alongside the weights, scaled by a learning rate η. Here we fixthreshold = 0(bias = 0) and set η = 1 so every weight stays a small integer, and we can watch how weight updates alone change the 3×3 template while the cutoff stays fixed.
3. Watching PVer Learn, Cycle by Cycle (Epochs)
Because A, B, and C share pixels—all three pass through the center square—changing wires to fix A also changes the score s that B and C will get. Showing each picture once isn’t enough. We have to cycle through the whole list (A → B → C) in repeated passes called epochs (calling the starting state before learning epoch 0) until an entire pass finishes with zero errors.
We can read the training run from left to right in four columns:
- ① Present: the image the teacher holds up right now.
- ② Compute (old weights): the score
s, answery, and errorebefore any weight changes. - ③ Learn: the 3×3 template before and after the update (yellow frames mark the weights that changed in this step).
- ④ Effect (new weights): how the updated template would now score A, B, and C.
Epoch 1: Two Mistakes, Two Repairs
Let’s follow the three steps of Epoch 1:
- Step 1 (Image A): Starting from all zeros, A gets score
s = 0—too cautious (e = +1).PVeradds+1to A’s three middle-column squares. Look at column ④ right after Step 1: A now passes (s = 3 ✓), but fixing A just broke both B (s = 1 ✗) and C (s = 1 ✗), because turning up the center square pushed their scores above0. - Step 2 (Image B): With those new weights, B gets score
s = 0 + 1 + 0 = 1—too eager (e = −1).PVersubtracts1across B’s middle row: middle-left and middle-right drop to−1(red), and the shared center square drops back to0(1 → 0). In column ④ we now haveA ✓ (s = 2),B ✓ (s = −2), andC ✓ (s = 0). - Step 3 (Image C): Because Step 2 already returned the center weight to
0, C’s diagonal getss = 0 + 0 + 0 = 0—correct (e = 0,no change).
Steps 1, 2, and 3 walked through all three error cases (+1, −1, 0) in one pass. Still, because weights changed mid-epoch after A was checked, PVer has to run one more cycle to verify that Step 2 didn’t undo Step 1.
Epoch 2: The Zero-Error Confirmation Pass
In Epoch 2, A (s = 2 > 0), B (s = −2 ≤ 0), and C (s = 0 ≤ 0) all finish with e = 0 and no change. Six steps in total, two updates, Errors per epoch: 2 → 0—training stops.
4. What Happened to the Center Pixel?
Let’s look closer at what happened in those six steps:
- Fixing one example can break another.
In Step 1, repairing A broke B and C (✓ → ✗). In Step 2, repairing B also fixed C before C even got its turn. That tug-of-war is why a single pass is not enough—only a full zero-error epoch shows that one set of weights works for all examples at once. - Why did the center pixel end up at
0—even though it belongs to the vertical line?
Compare the template we built by hand (0 1 0 / 0 1 0 / 0 1 0withthreshold = 2.5) with the templatePVerlearned (0 1 0 / -1 0 -1 / 0 1 0withthreshold = 0). Learning didn’t copy our mask; it settled on+1at top and bottom,−1on the left and right, and0in the middle.- Mechanically: Step 1 (A) pushed the center up (
0 → +1), and Step 2 (B) pulled it right back down (+1 → 0). Since A’s top-middle (+1) and bottom-middle (+1) weights already gaves = 2 > 0, A didn’t need the center weight. - Intuitively: The center square is black in A, B, and C. Imagine playing Guess Who? when every suspect is wearing glasses—asking “Are they wearing glasses?” gives you no clue who is who. Putting
+1on the center square helps B and C just as much as A. The tug-of-war canceled the shared pixel out to0and kept only pixels that tell A apart from B and C.
- Mechanically: Step 1 (A) pushed the center up (
- Errors per epoch (
2 → 0) is a baby loss curve.
Counting mistakes per pass (2in Epoch 1,0in Epoch 2) is a small version of the training error curves we watch when training larger neural networks.
5. What Did PVer Actually Learn?
PVer made zero errors on A, B, and C. Does that mean it really recognizes “Is this the middle vertical line?” across all 512 possible 3×3 pictures?
Let’s test the learned template (0 1 0 / -1 0 -1 / 0 1 0, threshold = 0) on six 3×3 images that PVer never saw during training:
Let’s check the verdicts against our question (“Is this the middle vertical line?”):
- Middle column with the center missing (
s = 2 → Yes ✗): Because the center weight is0,PVercannot tell whether the center pixel is black or white. Even with a hole in the middle, the line still scoress = 1 + 1 = 2 > 0and gets a wrong Yes. - Single dot at top-middle (
s = 1 → Yes ✗) and top horizontal row (s = 1 → Yes ✗): Both touch the+1weight at top-middle and miss the−1weights on the middle row, sos = 1 > 0produces Yes even for a single dot or a horizontal line. - Left and right vertical columns (
s = −1 → No ✓) and all 9 pixels black (s = 0 → No ✓): The left and right columns each hit a−1weight (s = −1 ≤ 0), and on an all-black image the two+1and two−1weights cancel out (s = 0 ≤ 0). Since none of these three is the middle vertical line, No is the right answer.
A machine only learns what its examples force it to distinguish. Three pictures (A, B, C) were enough to separate A from a middle row and a diagonal, and nothing more.
What’s Next?
If three clean examples leave PVer with blind spots like these, what happens when we add more examples or ask different questions?
In the next posts, we will add images with stray pixels to see how extra examples sharpen the template, train detectors for horizontal (PHori) and diagonal (PDiag) lines, and then try a 3×3 corner question (PXor) where the weights keep changing and never settle—the kind of problem Marvin Minsky and Seymour Papert used in their 1969 critique.





