Sikau

Artificial intelligence · Day 10 · about 45 min

Capstone: A neuron that learns

The perceptron — and why XOR defeats it.

Where neural networks began

In 1958 Frank Rosenblatt built the perceptron, a machine that learned to recognise simple shapes by adjusting its own weights. The press predicted thinking machines within years. In 1969 Marvin Minsky and Seymour Papert's book *Perceptrons* showed a single perceptron can't even learn XOR — and funding dried up for over a decade.

The fix, stacking neurons in layers and training them with backpropagation, was popularised in 1986 and is the ancestor of every deep network today, including large language models. Today you'll build the single neuron, watch it learn AND and OR, and watch it fail on XOR — for a reason you can draw.

A weighted vote

A perceptron multiplies each input by a weight, adds a bias, and outputs 1 if the total is above zero, otherwise 0. The weights say how much each input matters; the bias shifts the threshold. With two inputs, the boundary w₁x₁ + w₂x₂ + b = 0 is a straight line through the plane — everything on one side is 1, the other side 0.

function perceptron(weights, bias, inputs) {
  const sum = inputs.reduce((s, x, i) => s + x * weights[i], bias);
  return sum > 0 ? 1 : 0;
}
perceptron([1, 1], -1.5, [1, 1]); // 1 — this is AND
perceptron([1, 1], -1.5, [1, 0]); // 0

The rest of this lesson

  • The learning ruleexplain
  • One updatepredict
  • Separable or not?match
  • The updatefill
  • Train a perceptronchallenge
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 10 lessons of Artificial intelligence