Deep Learning Slides 📂 Introduction · 3 of 18 37 min read

Rosenblatt's Perceptron: The First Learning Machine

Go back to 1958, where deep learning began. This visual guide walks through Rosenblatt's perceptron step by step — inputs, weights, bias, and the step function — then the learning rule that lets it fix its own mistakes, why it masters AND and OR but hits a wall on XOR, and how to code it in Python.

Rosenblatt's Perceptron

In 1958 a psychologist wired up a machine that could learn from its own mistakes. It was the first algorithm to adjust its own weights — the spark that every neural network since has been built from.
The First Learning Machine Weights & Bias The Learning Rule The XOR Wall

Press Next → or use ← → arrow keys

Section 01

1958: A Machine That Learns

Frank Rosenblatt's learning machine
Cornell psychologist Frank Rosenblatt built a room-sized machine wired to a 20×20 grid of photocells. Shown images, it guessed a category, was told right or wrong, and rewired its own weights with tiny motors turning potentiometers. No one programmed the answer — it learned it. The press called it the embryo of a machine that would one day walk, talk, and reproduce itself.
1958Rosenblatt publishes the perceptron
400Photocells feeding the input layer
1Neuron — a single binary classifier
💡
Why it still matters

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.

Section 02

Borrowed From the Brain

The perceptron is a stripped-down cartoon of a biological neuron — and the mapping is almost one-to-one.

Dendritesreceive signals Cell bodysums & fires Thresholdfire or stay quiet Axonoutput inputs xᵢΣ wᵢxᵢ + bstep(z)ŷ ∈ {0,1}
🧠
A neuron that decides

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.

Section 03

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.

x₁ x₂ x₃ +b w₁w₂w₃ Σ step ŷ
⚖️
The bias is a "0th weight"

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.

Section 04

The Math in Three Steps

The whole forward computation is just a dot product, a bias, and a threshold.

z = w·x + b = Σ wᵢxᵢ + b
1 · Weighted sum
ŷ = 1 if z ≥ 0, else 0
2 · Step activation
ŷ = step(w·x + b)
3 · The prediction
The step (Heaviside) function output 1 output 0 z = 0 (threshold)
✂️
Hard, not smooth

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.

Section 05

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.

x₁ x₂ w·x + b = 0 w class 1 class 0
📐
This is the key limitation in disguise

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.

Section 06

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:

wᵢ wᵢ + η · (y ŷ) · xᵢ
η = learning rate · y = true label · ŷ = prediction
CaseError (y − ŷ)What happens to the weights
Correct prediction0No change — the rule leaves weights alone
Predicted 0, should be 1+1Add η·x — push weights toward firing
Predicted 1, should be 0−1Subtract η·x — push weights away from firing
🎯
Learn only from mistakes

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.

Section 07

The Training Algorithm

Put the rule in a loop and you have the complete perceptron learning algorithm:

1
Initialize all weights and the bias to zero (or small random values).
2
For each training example (x, y), compute z = w·x + b and the prediction ŷ = step(z).
3
Update every weight: wᵢ ← wᵢ + η(y − ŷ)xᵢ, and b ← b + η(y − ŷ).
4
Repeat over the whole dataset for several epochs — until no example is misclassified.
🔁
One pass is an "epoch"

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.

Section 08

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 yz = w·x + bŷUpdate?
00001yes → push down
111< 00yes → push up
100variescorrect over time
010variescorrect over time
It converges to w₁ = w₂ = 0.2, b = −0.3

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.

Section 09

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.

AND (0,0) (1,0)
OR (0,0) (1,0)
🟢
Linearly separable = learnable

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.

Section 10

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.

XOR — impossible for one line (0,0)→0 (1,0)→1 (0,1)→1 (1,1)→0
🧱
The critique that froze the field

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.

Section 11

The Convergence Theorem

If a dataset is linearly separable, the perceptron learning rule is guaranteed to find a separating boundary in a finite number of updates — no matter where it starts. It's one of the earliest and cleanest convergence proofs in machine learning.
Separable data → guaranteed to converge
Non-separable data → loops forever
1/γ²Update bound shrinks with a wider margin γ
⚠️
The catch

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.

Section 12

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
🔍
Notice what's missing

No gradients, no loss function, no calculus — just the error-driven update. That simplicity is the whole historical point.

Section 13

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))
🧩
Still a linear classifier

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.

Section 14

7 Things to Remember

  The perceptron in a nutshell
1It's one neuron. Inputs × weights, add a bias, threshold — a single binary decision.
2It learns from mistakes. Weights only change when a prediction is wrong: w ← w + η(y − ŷ)x.
3The boundary is a line. A perceptron can only solve linearly separable problems.
4AND and OR work; XOR doesn't. XOR needs a curved boundary a single neuron can't draw.
5Convergence is guaranteed — but only when the data is separable.
6The step function blocks gradients, so smooth activations replaced it for deep learning.
7Stacking solved XOR. Hidden layers + backpropagation grew directly out of this idea.
🚀
From one neuron to modern AI

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.