A · One neuron
The Perceptron
A weighted sum, a bias and a threshold: the simplest model that makes a decision, and the unit every neural network is built from.
Try it: A1 · The Neuron
Intuition
A perceptron takes a few numbers in and answers yes or no. It multiplies each input by a weight that says how much that input matters, adds the results together with a bias, and fires if the total is above zero. That's all. It is a model of a decision: "weigh the evidence, then commit."
Picture two inputs as a point on a plane. The perceptron's rule "weighted sum above zero" splits the plane with a straight line: on one side it says 1, on the other 0. The weights set the line's direction, the bias slides it. Every perceptron, whatever its weights, is just a choice of line.
This is why the perceptron is the first model to understand: everything later in machine learning keeps its weighted sum and changes what happens around it. Drop the threshold and you get linear regression. Soften it and you get the sigmoid neuron. Stack many and you get a deep network.
The math
For inputs \(x_1, \dots, x_d\), weights \(w_1, \dots, w_d\) and bias \(b\), the perceptron computes a weighted sum, then a step:
\[ z = \sum_{j=1}^{d} w_j x_j + b = \mathbf{w}^\top \mathbf{x} + b, \qquad \hat{y} = \operatorname{step}(z) = \begin{cases} 1 & z > 0 \\ 0 & z \le 0 \end{cases} \]The decision boundary is where \(z = 0\): the set of points with \(\mathbf{w}^\top \mathbf{x} + b = 0\). In two dimensions that is a line, in three a plane, in general a hyperplane. The weight vector \(\mathbf{w}\) is perpendicular to it and points toward the side that answers 1. The distance from the origin to the boundary is \(|b| / \lVert\mathbf{w}\rVert\), so the bias decides how far the line is from the centre.
Scaling all weights and the bias by the same positive number changes nothing: \(2z\) has the same sign as \(z\). A perceptron is really a direction and an offset, not a particular set of numbers.
Worked example: AND. Take \(w_1 = w_2 = 1\) and \(b = -1.5\).
| \(x_1\) | \(x_2\) | \(z = x_1 + x_2 - 1.5\) | \(\hat{y}\) |
|---|---|---|---|
| 0 | 0 | −1.5 | 0 |
| 0 | 1 | −0.5 | 0 |
| 1 | 0 | −0.5 | 0 |
| 1 | 1 | 0.5 | 1 |
Only \((1, 1)\) clears the threshold. Change the bias to \(b = -0.5\) and three corners fire: that is OR. Same neuron, different bias, different logic gate.
What one perceptron cannot do
A perceptron can only represent problems whose two classes a single straight line can separate: linearly separable problems. XOR (output 1 when exactly one input is 1) is the classic failure. Its 1s sit on one diagonal of the square and its 0s on the other, and no line puts both 1s on one side and both 0s on the other.
There are two ways out, and both shaped the field. Change the inputs: add \(x_1 x_2\) as a third input and XOR becomes separable, which is feature engineering. Or chain perceptrons: one layer computes OR and NAND, a second computes their AND, which is XOR. That second idea is a deep network.
Variants
- Bias as a weight. Add a constant input \(x_0 = 1\); then \(b\) is just \(w_0\), and the model is a pure dot product \(\mathbf{w}^\top \mathbf{x}\). Many textbooks write it this way.
- ±1 labels. Using \(\hat{y} = \operatorname{sign}(z) \in \{-1, +1\}\) instead of \(\{0, 1\}\) makes the learning rule a single line.
- Smooth neurons. Replacing the step by a smooth curve (a sigmoid, tanh or ReLU) gives a neuron whose output changes a little when a weight changes a little. That is what makes gradient-based learning possible; see Activation functions.
History
In 1943 Warren McCulloch and Walter Pitts described an idealised neuron that sums inputs and fires above a threshold, and showed networks of them can compute logic. Frank Rosenblatt's perceptron (1958) added the crucial part: weights that are learned from examples. He built it as a machine, the Mark I Perceptron, with motor-driven potentiometers for weights and a 20×20 grid of photocells as its eye. In 1969 Marvin Minsky and Seymour Papert's book Perceptrons proved rigorously what a single layer cannot compute, including XOR; it is often blamed for a decade of reduced interest in neural networks, until multi-layer networks trained by backpropagation answered it in the 1980s.
Connections
Leads to
- The Perceptron Learning RuleThe learning rule finds a perceptron's weights from examples, instead of picking them by hand.
- Linear RegressionLinear regression is a perceptron without the threshold: the weighted sum itself is the prediction.
- The Sigmoid FunctionThe sigmoid replaces the perceptron's hard step with a smooth one, so small changes in the weights cause small changes in the output.
- Deep NetworksA deep network is many neurons, arranged in layers that feed each other.
Further reading
- But what is a neural network? (3Blue1Brown)A visual first look at neurons, weights and biases: the picture behind the Challenge's diagram.
- Perceptrons, chapter 1 of Neural Networks and Deep Learning (Michael Nielsen)Builds logic gates out of perceptrons, just like the AND gate here, then shows why smoother neurons come next.
- Perceptron (Wikipedia)The definition, the history from Rosenblatt to Minsky and Papert, and why one perceptron can't do XOR.