Rosenblatt's Perceptron
Press Next → or use ← → arrow keys
1958: A Machine That Learns
Strip away the motors and photocells and the perceptron is the exact neuron sitting inside today's deep networks: inputs, weights, a bias, a sum, and an activation. Understand this one unit and you understand the atom of all deep learning.
Borrowed From the Brain
The perceptron is a stripped-down cartoon of a biological neuron — and the mapping is almost one-to-one.
A real neuron fires only when incoming signals cross a threshold. The perceptron copies exactly that: add up weighted inputs, and if the total clears a bar, output a 1 — otherwise a 0.
Anatomy of a Perceptron
Every input gets a weight. A bias shifts the threshold. Sum them, pass through a step function, and out comes a single yes/no decision.
Treat the bias as a weight on a constant input of 1. It lets the decision boundary sit anywhere — without it, every boundary would be forced through the origin.
The Math in Three Steps
The whole forward computation is just a dot product, a bias, and a threshold.
The step function jumps instantly from 0 to 1 — its derivative is zero everywhere. That's exactly why gradient descent can't train it, and why later neurons switched to sigmoid and ReLU.
A Perceptron Draws a Line
Geometrically, w·x + b = 0 is a straight line (a hyperplane in higher dimensions). Everything on one side is class 1, everything on the other is class 0. The weight vector w points perpendicular to it.
Because the boundary is always straight, a perceptron can only separate classes a single line can split. Hold onto that thought — it returns as the XOR problem.
The Learning Rule — The Heart of It
Rosenblatt's breakthrough wasn't the neuron — it was how it learns. After each prediction, nudge every weight in proportion to the error:
| Case | Error (y − ŷ) | What happens to the weights |
|---|---|---|
| Correct prediction | 0 | No change — the rule leaves weights alone |
| Predicted 0, should be 1 | +1 | Add η·x — push weights toward firing |
| Predicted 1, should be 0 | −1 | Subtract η·x — push weights away from firing |
When the perceptron is right, nothing moves. Every update is a small correction aimed squarely at the errors — the bias updates the same way, with x fixed at 1.
The Training Algorithm
Put the rule in a loop and you have the complete perceptron learning algorithm:
A single sweep through the data rarely fixes everything. Repeat for multiple epochs; if the data is linearly separable, the weights are guaranteed to settle on a working boundary.
Worked Example: Learning AND
Train on the AND gate with η = 0.1, starting from w = [0, 0], b = 0. Watch the weights self-correct on the misclassified rows:
| x₁ | x₂ | Target y | z = w·x + b | ŷ | Update? |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | yes → push down |
| 1 | 1 | 1 | < 0 | 0 | yes → push up |
| 1 | 0 | 0 | varies | — | correct over time |
| 0 | 1 | 0 | varies | — | correct over time |
After a few epochs the perceptron settles on weights where only x₁ = x₂ = 1 pushes the sum above zero — exactly the AND truth table. It discovered the logic from examples alone.
AND & OR: Perfectly Separable
Plot the four input combinations as points. For AND and OR, a single straight line cleanly splits the 1s from the 0s — so the perceptron learns them easily.
Green dots are output 1, red are output 0. In both gates one line does the job, so Rosenblatt's rule finds the weights every time.
The XOR Wall
Now try XOR — output 1 when the inputs differ. The two green points sit on opposite corners, and no single straight line can separate them from the red ones.
In 1969, Minsky & Papert's book Perceptrons proved this limit. Funding dried up and the first "AI winter" set in. The fix — stacking perceptrons into hidden layers — wouldn't be trainable until backpropagation arrived in the 1980s.
The Convergence Theorem
The guarantee holds only when a separating line exists. On XOR or any noisy, overlapping data the rule never stops — which is why modern training uses smooth losses and gradient descent instead.
The Perceptron in ~15 Lines
The entire algorithm is short enough to write from scratch with NumPy:
import numpy as np
def train_perceptron(X, y, lr=0.1, epochs=10):
w = np.zeros(X.shape[1])
b = 0.0
for _ in range(epochs):
for xi, target in zip(X, y):
z = np.dot(xi, w) + b
y_hat = 1 if z >= 0 else 0
error = target - y_hat # -1, 0, or +1
w += lr * error * xi # the learning rule
b += lr * error
return w, b
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([0,0,0,1]) # AND gate
w, b = train_perceptron(X, y)
print(w, b) # ~[0.2 0.2] -0.3
No gradients, no loss function, no calculus — just the error-driven update. That simplicity is the whole historical point.
The Modern One-Liner
scikit-learn ships a production Perceptron class — the same algorithm, vectorized and battle-tested:
from sklearn.linear_model import Perceptron
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
X, y = load_iris(return_X_y=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.2)
clf = Perceptron(eta0=0.1, max_iter=1000, random_state=42)
clf.fit(X_tr, y_tr)
print(clf.score(X_te, y_te))
sklearn handles multi-class with a one-vs-rest bank of perceptrons — but each boundary is still a straight line. For curved boundaries you need the multilayer version.
7 Things to Remember
Every deep network is a descendant of Rosenblatt's 1958 machine. Master this single unit and the multilayer perceptron, CNNs, and transformers all become variations on a theme you now understand.