Foundations

The perceptron

A perceptron draws a learned linear decision boundary by thresholding a weighted sum of input features.

Updated

1

Concept

The perceptron is a small model with a large historical footprint. It receives a feature vector xx, stores one weight per feature in ww, adds a bias bb, and computes z=wx+bz=w\cdot x+b. A threshold turns that score into one of two classes. With labels encoded as 1-1 and +1+1, the prediction is the sign of zz.

Each weight controls how one feature contributes. A positive weight raises the score as its feature increases; a negative weight lowers it. The absolute magnitude reflects sensitivity in the units presented to the model. The bias is an intercept: it changes the baseline score when all input features are zero. Feature scaling matters because a large numerical range can dominate even when its underlying property is not more informative.

In two dimensions, the equation w1x1+w2x2+b=0w_1x_1+w_2x_2+b=0 describes a line. Points on one side produce positive scores and points on the other produce negative scores. The vector ww is perpendicular to that line. Changing the weight ratio rotates the boundary; changing bb shifts it without rotation. In more dimensions, the same boundary is a hyperplane.

The classic perceptron learning rule reacts to mistakes. For a misclassified example (x,y)(x,y), one form updates ww+ηyxw\leftarrow w+\eta yx and bb+ηyb\leftarrow b+\eta y, with learning rate η>0\eta>0. A positive example predicted negative pulls the weight vector toward that input; a negative example predicted positive pushes it away. Correct examples need no update under the basic rule.

If a dataset is linearly separable, the perceptron convergence theorem says this mistake-driven procedure reaches some separating hyperplane after finitely many mistakes under standard assumptions. It does not promise the widest margin, calibrated probabilities, or good generalization. The chosen separator depends on data order, scaling, initialization, and updates. Separability is a property of the supplied representation, not necessarily of the underlying world.

XOR exposes the limitation. Label (0,0)(0,0) and (1,1)(1,1) one class, and (0,1)(0,1) and (1,0)(1,0) the other. No line divides the diagonal pairs correctly. Training longer cannot make one perceptron represent a non-linear boundary. Adding useful transformed features or composing multiple units with a nonlinearity changes the representation and can solve it. That step leads directly to multilayer networks.

The hard threshold also has zero derivative almost everywhere and is discontinuous at the boundary, which makes ordinary gradient-based learning unsuitable. Modern binary classifiers often keep the linear score but use a differentiable sigmoid during training and a probabilistic loss. The decision may still be thresholded later. Separating training score, probability interpretation, and final policy threshold avoids confusion.

Language models contain vastly more machinery, yet perceptron logic remains visible. A neuron computes a weighted sum plus bias before an activation. Linear classification heads map hidden vectors to logits. Dot products score compatibility. The perceptron teaches the essential geometry: learned weights define a direction, bias defines an offset, and a model can only separate patterns made accessible by its representation.

When inspecting a fitted boundary, plot the examples and margins rather than reporting accuracy alone. A separator can classify the small training sample perfectly while lying dangerously close to every point, making tiny measurement noise reverse decisions.

2

Explain it like I am five

A museum guard scores each bag using a checklist: metal-object count weighs positively, a verified equipment tag weighs negatively, and a baseline bias shifts strictness. The scores are added. Above a threshold the bag receives inspection; below it passes. Changing weights rotates the policy’s boundary, while changing the bias slides it. No matter how the checklist is tuned, one straight boundary cannot isolate visitors arranged in an XOR checkerboard.

3

Teach it back

Explain the perceptron's weighted sum, bias, threshold, learning update, and linear-separability limitation with a two-feature example.

Minimum: 80 characters and 15 words. Your text stays only in this browser.

Saved only on this device.

Show a model answer

For features x, the perceptron computes z=w·x+b and assigns a class from the sign of z. In two dimensions z=0 is a line; weights set its orientation and bias shifts it. On a misclassified example, the update moves weights toward the correct labeled input. If no line separates the classes, as in XOR, updates cannot converge to a perfect separator because the representational limitation is structural, not an optimizer failure.

4

Check your understanding

1. What geometric object is z=0 for a two-feature perceptron?
Answer and explanation

A line — In n dimensions, the corresponding linear decision boundary is a hyperplane of dimension n-1.

2. Why can a single perceptron not solve XOR?
Answer and explanation

The positive and negative examples are not linearly separable — No single straight boundary places the diagonal XOR pairs on opposite sides.

Complete the teach-back and answer the quiz correctly to finish this lesson.

Sources

  1. Frank Rosenblatt (1958). The Perceptron: A Probabilistic Model for Information Storage and Organization in the Brain.