From Neurons to Networks
The perceptron
One artificial neuron, and its limits
Weighted inputs, a bias, a threshold - the smallest unit that can learn to draw one decision line, and the atom every neural network is built from.
Strip a neural network down to a single cell and you get the perceptron: it multiplies each input by a weight, adds them up with a bias, and fires a yes/no depending on whether the total clears a threshold. That's the whole machine. Yet this one tiny unit can learn - nudging its own weights every time it's wrong until it carves the plane into two clean halves. Understand this atom completely and you understand what every layer of every large language model is quietly doing, billions of times over.
The picture to hold in your head
One neuron, in math
Give the neuron two inputs, and . It holds two weights and one bias . First it computes a single number - the weighted sum, or pre-activation - which is just a plus the bias:
Weighted sum, then activation
Then is squashed through an activation function. The original perceptron uses the hardest possible one - a step (Heaviside) threshold that outputs a flat 1 or 0:
Swap that hard step for a smooth -curve and you have exactly the logistic regression unit from last lesson - the perceptron is its sharp-edged ancestor.
A neuron is a line
Here is the geometric heart of it. The neuron flips from "no" to "yes" precisely where crosses zero. The set of all inputs that sit exactly on that knife-edge - where the neuron is perfectly undecided - is
,
and in two dimensions that equation is a straight line (in higher dimensions, a flat hyperplane). The weight vector is the line's normal - it points perpendicular to the line, toward the "yes" side - and the bias slides the line toward or away from the origin. So the three knobs have crisp meanings: rotate the boundary; shifts it. A single neuron can only ever draw one straight cut through the world.
Teaching the line to place itself
The magic is that the neuron doesn't need us to pick good weights - it can find them. Show it a labelled point, let it guess , and if it's wrong, shove the weights a little toward getting that point right. Correct guesses are left untouched. That single sentence is the perceptron learning rule:
The perceptron update (fires only on mistakes)
The error is , , or . When the neuron is right it is , so nothing moves. When it wrongly says "no" to a "yes" point, the error is and the weights step toward that point ; when it wrongly says "yes", they step away. The learning rate (eta) sets how big each nudge is. Repeat over the data and, if a separating line exists, the boundary rotates itself into place - a fact called the perceptron convergence theorem.
Drive it yourself. Drag the three sliders to aim the line by hand, then hit Train to let the rule take over: it hunts for a misclassified point (ringed in amber), nudges the weights toward fixing it, and you watch the line pivot. Press Run to animate the whole descent to zero mistakes. Then switch the data to XOR and try again.
decision rule: fire 1 when z = -1·x₁ − 1·x₂ + 0 ≥ 0
12 points on the wrong side. Press Run to fix them.
Switch the data to XOR - and watch it fail forever
This exact failure, published in 1969, froze neural-network research for over a decade. The escape was not a cleverer single neuron but more of them: stack a hidden layer of neurons and each one draws its own line, then a second neuron combines their yes/no answers. Two lines can box in a corner; XOR falls instantly. That's the entire reason deep networks need depth and non-linear activations - the subject of Lessons 20 to 21.
import numpy as np
def step(z):
return 1 if z >= 0 else 0
w = np.array([-1.0, -1.0]) # weights w1, w2 (a deliberately bad start)
b = 0.0 # bias
eta = 0.15 # learning rate
for epoch in range(100): # sweep the data repeatedly
mistakes = 0
for x, y in data: # x = [x1, x2], y = 0 or 1
y_hat = step(w @ x + b) # z = w·x + b, then threshold
err = y - y_hat # +1, 0, or -1
if err != 0:
w += eta * err * x # nudge weights toward this point
b += eta * err # and shift the bias
mistakes += 1
if mistakes == 0:
break # separated - the line is doneCheck yourself
What shape is the decision boundary a single two-input neuron can draw?
Why can a lone perceptron never solve the XOR problem?
Recall: state the perceptron learning rule, and say when it changes the weights.
Tie the update equation to the fact that it fires only on mistakes. Try to state it, then check.
Lock it in
- A perceptron is one cell: weighted sum , then a step threshold fires 1 or 0.
- is a straight line; rotates it and shifts it.
- The learning rule moves weights only on mistakes, toward the point it got wrong.
- One neuron draws one line, so XOR (not linearly separable) needs a hidden layer.
Primary source
Ask your teacher