Part VIII — Neural Network Fundamentals, Backpropagation & Optimizers · Chapter 1

The perceptron & the XOR problem

Hook

Part II's Chapter 11 found the best possible line separating two classes by solving an optimization problem. What's the simplest algorithm that finds merely a working line at all?

Intuition
Step 0 — next up: (3, 6), class A

Same two clusters as the SVM — short for Support Vector Machine — chapter. Take a step: one point gets checked against the current line. If it's already on the right side, nothing happens. If it's wrong, the line moves — just enough to nudge that one point onto its correct side.

Formalize

This is the perceptron, one of the oldest learning algorithms. It's a single artificial neuron: a weight vector ww and bias bb predict y^=sign(wx+b)\hat y = \text{sign}(w \cdot x + b). Whenever a prediction is wrong, it corrects itself by exactly the term that caused the error:

ww+ηyx,bb+ηyw \leftarrow w + \eta\, y\, x, \qquad b \leftarrow b + \eta\, y
  • ww — the weight vector, the perceptron's current line direction.
  • bb — the bias, shifting the line away from the origin.
  • η\eta — the learning rate, controlling how big a correction each mistake causes.
  • yy — the true label of the point just checked, +1+1 or 1-1.
  • xx — the input point's coordinates.
  1. No calculus needed

    Whenever the prediction is wrong (with yy the true label, +1+1 or 1-1), the rule above nudges ww and bb directly toward correctness — no calculus, no loss function to minimize, just "if wrong, shift toward being right."

Play
w = (0.0, 0.0), b = 0.0 — testing (3, 6)

Watch ww and bb directly. They only change on the two steps that actually hit a misclassified point — every other step leaves them untouched. The line isn't being optimized; it's being corrected, one mistake at a time.

Worked example

Starting at w=(0,0)w=(0,0), b=0b=0:

  1. First point — a mistake

    (3,6)(3,6) is class A (label 1-1), but sign(0)=+1\text{sign}(0) = +1 — wrong. The update: w(0,0)+1(1)(3,6)=(3,6)w \leftarrow (0,0) + 1\cdot(-1)\cdot(3,6) = (-3,-6), b0+1(1)=1b \leftarrow 0 + 1\cdot(-1) = -1.

  2. Next three points — no change

    Already correctly classified by this new line.

  3. Point five — another mistake

    (5,4)(5,4) is class B (+1+1), but the current line predicts 1-1 — wrong again: w(3,6)+(5,4)=(2,2)w \leftarrow (-3,-6) + (5,4) = (2,-2), b1+1=0b \leftarrow -1+1=0.

  4. Converged

    From here, all eight points — checked again in a full second pass — are already correct. Just two corrections, out of sixteen checks, and it's converged to w=(2,2)w=(2,-2), b=0b=0: the line y=xy=x.

Checkpoint

Keep taking steps until the line correctly separates every single point.

Step 0 — next up: (3, 6), class A
Take a step to try it
Summary
ww+ηyx,bb+ηyw \leftarrow w + \eta\, y\, x, \qquad b \leftarrow b + \eta\, y

The perceptron is guaranteed to converge on any linearly separable data — but unlike the SVM's max-margin line, it just stops at the first separator it finds, with no guarantee it's the widest one. It's also the smallest possible building block of a neural network: the next chapters are about what happens when you stack many of these together.