Perceptron Learning Rule: Weight Updates on a Tiny Dataset, Step by Step
Follow a perceptron through three labelled points, see each sequential correction, and verify the separating boundary after a mistake-free second pass.
KnowledgeGate Team
Exam prep & CS education

The perceptron formula looks simple until the prediction, target label, bias and update order all have to be tracked together. With one fixed convention, the weights are updated across three labelled points until every point is classified correctly. These three points make the mechanics visible; they do not represent a realistic machine-learning task.
Perceptron learning rule: score, decision and update
For a two-input perceptron, calculate the score
z = w1*x1 + w2*x2 + b
Here, w = (w1, w2) is the weight vector, b is the bias, x = (x1, x2) is the input, y is the target in {-1, +1}, and eta is the learning rate. The decision rule is:
If
z >= 0, predicty_hat = +1.Otherwise, predict
y_hat = -1.
Training is sequential. If y_hat != y, update using w_new = w_old + eta*y*x and b_new = b_old + eta*y. If the prediction is correct, change nothing. The state produced by one row is the state used for the very next row.
Some 0/1-labelled formulations use an error such as y - y_hat. That is valid within its own convention, but mixing it with the -1/+1 update rule produces wrong updates. Perceptron and Activation Functions Explained: Worked Examples and Exam Traps uses a 0/1 one-step example to compare activation functions. A -1/+1 trace through complete epochs and boundary movement tests a different skill. In the wider picture, the perceptron is one classical learning method among the Approaches to AI.

Tiny perceptron dataset and starting state
The ordered dataset is:
Point | Input | Target |
|---|---|---|
A |
|
|
B |
|
|
C |
|
|
A belongs to the positive class, while B and C belong to the negative class. Before calculating anything, lock these choices: row order A, B, C; eta=1; initial w=(-1,1); initial b=0; and z=0 predicts +1. One epoch is one complete pass through A, B and C in that order.
Readers looking beyond this single algorithm can browse Coding & Skill Development Courses.
Perceptron first pass: calculate every weighted sum
For A, use the starting state:
z=(-1)(2)+(1)(1)+0=-1
The prediction is -1, but the target is +1, so update. We get delta w=1*(+1)*(2,1)=(2,1) and delta b=1. Therefore, w=(-1,1)+(2,1)=(1,2) and b=0+1=1.
For B, use the newly updated state, not the initial state:
z=(1)(-1)+(2)(-2)+1=-1-4+1=-4
The prediction -1 matches the target, so the state stays w=(1,2), b=1.
For C, that current state gives z=(1)(-2)+(2)(1)+1=-2+2+1=1. The prediction is +1, but the target is -1. Thus, delta w=1*(-1)*(-2,1)=(2,-1) and delta b=-1. The first epoch ends at w=(1,2)+(2,-1)=(3,1), b=0.
Point | State before |
|
|
| Update | State after |
|---|---|---|---|---|---|---|
A |
|
|
|
|
|
|
B |
|
|
|
| None |
|
C |
|
|
|
|
|
|
Perceptron second pass: verify convergence and the boundary
Start epoch 2 at w=(3,1), b=0. Now score every point:
A:
z=3(2)+1(1)+0=7, so the prediction is+1.B:
z=3(-1)+1(-2)+0=-5, so the prediction is-1.C:
z=3(-2)+1(1)+0=-5, so the prediction is-1.
All three predictions match. Epoch 2 contains zero mistakes, so it makes zero updates. The final state for this dataset, starting state and row order is w=(3,1), b=0. These are not unique weights. Many separating lines could classify the same three points.
The final decision boundary is where the score is zero: 3*x1+x2=0, or x2=-3*x1. The initial boundary was -x1+x2=0. After updating on A, the intermediate boundary was x1+2*x2+1=0.

Why a perceptron update moves the boundary
For a misclassified positive point, adding eta*x increases that point's score. For a misclassified negative point, subtracting eta*x decreases its score. Updating the bias shifts the entire boundary too, rather than changing only its angle.
Point A makes the movement measurable. Before its update, the signed margin is y*z=(+1)(-1)=-1. Immediately afterwards, A's new score is (1)(2)+(2)(1)+1=5, so its signed margin rises from -1 to 5, an increase of 6. The same increase follows from eta*(||x||^2+1)=1*(2^2+1^2+1)=6. The final +1 represents the bias update.
Repeated epochs are necessary because fixing one point can change the scores of points seen earlier. Convergence also requires linear separability. For XOR labels (0,0)->-1, (0,1)->+1, (1,0)->+1, (1,1)->-1, no single straight line separates the two classes, so the basic perceptron has no convergence guarantee.
Perceptron weight-update mistakes to avoid
Most wrong solutions come from a small set of traps:
Forgetting
b: the computed score and boundary are incomplete. Include the bias in both scoring and mistake updates.Mixing label conventions: a 0/1 error formula does not belong inside this
-1/+1calculation. Declare one convention and keep it.Updating a correct prediction: this changes a state that should remain fixed. Check
y_hat != yfirst.Reusing epoch-starting weights: online updates are sequential. Carry each new state to the next row.
Changing the tie rule: whether
z=0maps to positive or negative can change a trace. State the rule before starting.
C exposes the common sign error. At w=(1,2), b=1, it is a negative example with positive score 1. The correct correction is (-1)*(-2,1)=(2,-1), not simply adding C's vector (-2,1). That wrong sign would push this negative point further towards a positive prediction.
Different data orders and initial values can produce another valid separating vector or a different number of updates. The learning rule seeks a separator, not one canonical set of weights.
Perceptron exam questions: prediction, one update and limitations
Common question forms fall into three types:
Compute
zand apply the declared threshold to find the class.Perform exactly one online update, including the bias.
Decide whether convergence is possible by checking linear separability.
Here is an independent update check. Let w=(1,1), b=0.5, x=(2,-1), y=-1 and eta=0.5. The score is z=1(2)+1(-1)+0.5=1.5, so y_hat=+1, a mistake. Then delta w=0.5*(-1)*(2,-1)=(-1,0.5) and delta b=-0.5. The new state is w=(0,1.5), b=0.
Check the same point again: z_new=0(2)+1.5(-1)+0=-1.5, which predicts -1 correctly. For follow-on recognition practice, try Artificial Neural Networks MCQs: 10 Solved Questions, while keeping in mind that individual questions may declare another update convention.
Perceptron learning rule: the short version and next step
The loop has four parts: calculate the weighted sum, apply the declared threshold, update only after a mistake, and run another pass until a full pass makes no changes or a stopping rule is reached.
In this trace, the state moved from w=(-1,1), b=0 to w=(3,1), b=0. The second pass produced scores 7, -5 and -5, with no updates. For a broader guided path through AI, AI & ML for Placements | Generative AI Placement Course is an optional next step.
Keep learning
Data Mining Functionalities Explained: Eight Tasks with One Worked Dataset
Learn the eight data mining tasks through six customer records and five baskets. Follow each small calculation, then use question cues to identify the right functionality.
Perceptron and Activation Functions Explained: Worked Examples and Exam Traps
Follow one sample through net input, five activations, and a complete perceptron update. Then connect the arithmetic to XOR, gradients, output layers, and common mistakes.
Multi-Layer Perceptron and Backpropagation Explained with a Worked Example
Build a 2-2-1 neural network from its inputs to its loss, then trace backpropagation through every weight and bias. The complete update shows why each sign matters.
Perceptron and Activation Functions MCQs: 11 Solved Questions
Work through 11 practice problems covering perceptron sums and outputs, sign and sigmoid activation, separating lines, linear separability, and ANN weights.





