Skip to content
datarekha

Perceptron & the Update Rule

The original neural unit: predict sign(wᵀx + b), then nudge the weights toward every misclassified point until the classes are separated.

9 min read Intermediate GATE DA Lesson 91 of 122

What you'll learn

  • The perceptron predicts the sign of the linear score: ŷ = sign(wᵀx + b)
  • It learns by the update rule w ← w + η(y − ŷ)x, applied only to misclassified points
  • Each update rotates the decision boundary toward classifying the missed point correctly
  • It converges only if the data is linearly separable — a single layer cannot solve XOR

Before you start

Last lesson asked for the simplest unit that learns in the plainest sense — watches its own mistakes and corrects. Here it is, and it happens to be the original artificial neuron, the ancestor of every neural network. Its prediction is brutally simple: compute the linear score z = wᵀx + b, then output its sign. If z is positive, predict +1; if negative, predict −1.

Unpack the notation before trusting it. wᵀx says nothing more than “multiply each input feature by its own weight and add the results up”. The b — the bias — is a single constant that shifts that total up or down. The boundary z = 0 is a line, just as in logistic regression, but instead of a smooth probability the perceptron commits to a hard ±1.

What made it historic is how it learns:

  • no calculus,
  • no probability,
  • no loss to descend.

Instead, there is just a tiny correction applied every time it gets a point wrong. It repeats until it stops making mistakes — the way you twitch a steering wheel back each time the car drifts off its lane.

Predict with a sign, learn from mistakes

The prediction:

ŷ = sign(wᵀx + b)   →   +1 if wᵀx + b > 0,   −1 otherwise

The learning rule walks through the training points. When the prediction ŷ matches the true label y, do nothing. When it is wrong, nudge the weights:

w ← w + η (y − ŷ) xb ← b + η (y − ŷ)η = learning rate · (y − ŷ) is 0 when correct, ±2 when wrong
The error term (y − ŷ) is zero on correct points, so only mistakes change the weights.

The key is the error term (y − ŷ). When the prediction is right, y − ŷ = 0 and the weights do not move. When it is wrong — say y = +1 but ŷ = −1y − ŷ = +2, so we add a multiple of x to w. That pushes the score wᵀx up for this exact point, dragging it toward the positive side. Geometrically, each update rotates the decision boundary toward correctly classifying the point it just missed.

old: z = 0updatedy = +1, misclassifiedboundary rotates toward point
The positive point sat on the wrong side of the solid line; after one update the dashed boundary has rotated so the point is now classified +.

This repeats over the data, pass after pass. The Perceptron Convergence Theorem guarantees the process halts with zero errors. This guarantee holds only if the classes are linearly separable. That means some straight line (a flat hyperplane, in more than two dimensions) can be drawn with every positive point on one side of it and every negative point on the other. If no such line exists, the perceptron never settles; some point is always wrong, so the weights never stop moving.

That guarantee promises less than it appears to, and the gap is worth naming: converging is not the same as finding the best line. The perceptron stops the instant it makes zero mistakes on the training data. It therefore hands back whichever separating line it happened to stumble into — quite possibly one passing a hair’s breadth from a training point. Visit the points in a different order and you converge to a different line. Nothing in the algorithm prefers one over the other. “Halted” means no errors left, not widest gap found.

How GATE asks this

Almost always an MCQ or NAT asking for the effect of a single update. The prompt gives you:

  • w and b,
  • a misclassified point x and its true label y,
  • the learning rate η.

Compute the new weights or show that the score wᵀx moves toward the correct side. This single-neuron update is also the building block behind the neural-network questions GATE DA has asked every year (2024–2026). A conceptual variant asks why a single-layer perceptron cannot learn XOR — the answer being that XOR is not linearly separable.

Worked example — one update step

Current weights w = (1, 0) with bias b = −3. A point x = (2, 1) has true label y = +1. With learning rate η = 1, perform one update and check that wᵀx improves.

First confirm it is a mistake. The score is z = wᵀx + b = (1)(2) + (0)(1) − 3 = 2 − 3 = −1. It is negative, so the perceptron predicts ŷ = −1 — wrong, since the true label is +1. Apply the update. The error term is y − ŷ = +1 − (−1) = 2:

w_new = w + η·(y − ŷ)·x
      = (1, 0) + 1 · 2 · (2, 1)
      = (1, 0) + (4, 2)
      = (5, 2)

Now recompute the weighted score wᵀx for the same point with the new weights:

old wᵀx = (1)(2) + (0)(1) = 2
new wᵀx = (5)(2) + (2)(1) = 10 + 2 = 12

The score jumped from 2 to 12 — far more strongly positive, exactly as the prediction prompt anticipated. The weight vector grew in the direction of x, which is what rotates the boundary toward the point it had been missing.

The bias moves by the same rule. It is the half of the update people forget: b_new = b + η(y − ŷ) = −3 + 1·2 = −1. Put both halves together and the full score for this point is now z = wᵀx + b = 12 − 1 = 11, comfortably positive — so the perceptron would label it +1 this time. One update turned the mistake into a correct call.

In one breath

The perceptron — the original neuron — predicts ŷ = sign(wᵀx + b), a hard ±1. It learns with no calculus by the rule w ← w + η(y − ŷ)x applied only to misclassified points (the error term y − ŷ is 0 when correct). Each correction rotates the boundary toward the point it missed. The Convergence Theorem guarantees it halts with zero errors iff the data is linearly separable. That condition is also its fatal limit: it can never learn XOR, because no single line splits it.

Practice

Quick check

0/6
Q1Recall — Which statements about the single-layer perceptron are TRUE? (select all that apply)select all that apply
Q2Recall — When the perceptron's prediction ŷ already equals the true label y, what does the update rule w ← w + η(y − ŷ)x do?
Q3Recall — A perceptron is trained on data that is NOT linearly separable. What happens?
Q4Trace — Weights w = (1, 0), learning rate η = 1. A misclassified point x = (2, 1) has true label y = +1 and prediction ŷ = −1. After one update, what is the first component of the new weight vector w_new?numerical answer — type a number
Q5Trace — Continuing the example, after the update to w = (5, 2), what is the new score wᵀx for the same point x = (2, 1)?numerical answer — type a number
Q6Apply — Weights w = (0, 1), η = 1. A point x = (3, −2) with true label y = +1 is misclassified as ŷ = −1. What is the SECOND component of w_new?numerical answer — type a number

A question to carry forward

The perceptron learns — and then slams into a wall named XOR. Four points, two classes, and not one straight line on Earth can separate them. The single neuron loops forever, defeated by a problem a child solves at a glance.

The fix is the idea that launched deep learning: stop asking one neuron to do everything. Feed the outputs of several perceptrons into another perceptron. This creates a hidden layer between input and output, and suddenly curved, XOR-shaped regions come within reach. But the hard sign step has to go first: it is flat almost everywhere, so it tells a deeper network nothing about how to improve. Here is the thread onward:

  • how does stacking neurons into layers buy the power to carve any region?
  • what smooth activation must replace the sign so the stack can be trained?
  • what does a multi-layer network actually compute as a signal flows through it?

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Practice this in an interview

All questions
What does a single artificial neuron (perceptron) actually compute?

A single artificial neuron computes an affine score by taking a weighted sum of its inputs and adding a bias, then applies an activation function. A classic perceptron uses a hard threshold, while modern neurons commonly use sigmoid or ReLU; the bias shifts the decision boundary and the activation determines the output shape.

Walk me through how backpropagation works.

Backpropagation computes the gradient of the loss with respect to every weight and bias by applying the chain rule backward through the network and reusing values from the forward pass. An optimizer then uses those gradients, usually by subtracting a scaled gradient, to update the parameters.

What is backpropagation and how does the chain rule make it work?

Backpropagation uses the chain rule to compute the gradient of a scalar loss with respect to every model parameter by traversing the computation graph backward. It reuses intermediate gradients, making one forward pass and one backward pass far cheaper than calculating each parameter's gradient independently.

How does dropout work, and why must it behave differently during training and inference?

Dropout randomly zeroes each neuron's output with probability p during training, forcing the network to learn redundant representations and preventing co-adaptation of neurons. At inference, dropout is disabled and all neurons are active — but to keep expected activations the same as during training, outputs are scaled by 1/(1−p). Forgetting to switch modes produces incorrect, noisy predictions.

Related lessons

Explore further