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.
KnowledgeGate Team
Exam prep & CS education

A perceptron equation looks short, but a question can change the bias sign, activation convention, or update order. One unnoticed change spoils the answer. The reliable sequence is to calculate the net input, compare activation outputs at that fixed value, and apply the perceptron update only after computing the error.
1. What a perceptron computes
With input vector x, weight vector w, and bias b, a perceptron calculates z = w.x + b and produces y = f(z). The hard-step convention is:
step(z) = 1whenz >= 0step(z) = 0whenz < 0
State this convention before calculating. Some questions define the output at zero differently.
The bias shifts the decision boundary. Threshold notation may instead say w.x >= theta. It agrees with the bias form when b = -theta. Write that conversion first to prevent a sign mistake.
A classic perceptron applies a hard step for a binary decision. Modern neural networks commonly use differentiable or piecewise differentiable activations so gradients can guide training.
2. Worked example: forward pass and one perceptron update
Use x = (2, 1), target t = 1, initial weights w = (-0.2, 0.1), bias b = -0.3, and learning rate eta = 0.1.
z = (-0.2)(2) + (0.1)(1) - 0.3
z = -0.4 + 0.1 - 0.3 = -0.6
Since z < 0, the step gives y = 0, not the target 1. The sample is misclassified.
The perceptron update is w_new = w + eta(t-y)x and b_new = b + eta(t-y). Here, t-y = 1, so:
w_new = (-0.2, 0.1) + 0.1(1)(2, 1) = (0, 0.2)
b_new = -0.3 + 0.1(1) = -0.2
Now recheck the same sample:
z_new = (0)(2) + (0.2)(1) - 0.2 = 0
Under z >= 0 -> 1, the new output is 1. A convention assigning zero to class 0 would change this label, so the boundary convention is essential.

3. Feed the same net input through five activation functions
Keep z = -0.6 fixed. That isolates the effect of the activation function.
Step:
0, because-0.6 < 0.Sigmoid:
1/(1 + e^0.6), approximately0.354.Tanh:
tanh(-0.6), approximately-0.537.ReLU:
max(0, -0.6) = 0.Leaky ReLU with
alpha = 0.01:0.01(-0.6) = -0.006.
Step has range {0,1} for a hard decision. Sigmoid has range (0,1) for a binary output score. Tanh has range (-1,1) for zero-centred signed activations. ReLU has range [0,infinity) for sparse positive hidden activations. Leaky ReLU has range (-infinity,infinity) with a small negative-side slope.
For gradients, step is constant on either side of zero. Sigmoid and tanh can saturate at large input magnitudes. ReLU has zero slope for negative inputs, while this leaky ReLU keeps slope 0.01. No activation is universally best.

4. Why a network needs nonlinearity, and where a single perceptron stops
Suppose one layer computes h = W1x + b1 and the next computes o = W2h + b2, with no activation between them. Substitution gives o = (W2W1)x + (W2b1 + b2). This is still one affine map. Stacking more such layers cannot create nonlinear decision boundaries. Activations let stacked layers represent curved or piecewise relationships.
XOR shows the limit exactly. Its targets are 0 for (0,0) and (1,1), and 1 for (0,1) and (1,0). No single straight line separates the two classes, so one perceptron cannot represent XOR.
The perceptron learning rule converges for linearly separable training data under its standard assumptions. For non-separable data such as XOR, it is not promised to converge to a separating solution.
5. Choosing an activation by the layer's job
Function | Formula | Output range | Typical role | Main caution |
|---|---|---|---|---|
Step |
|
| Classic perceptron decision | No useful gradient away from the boundary |
Sigmoid |
|
| One binary output or non-exclusive labels | Saturates at large magnitudes |
Softmax |
| Each value in | Mutually exclusive multi-class output | Classes compete through normalisation |
Tanh |
|
| Signed hidden states in some architectures | Can saturate |
ReLU |
|
| Hidden layers | Zero negative-side slope |
Leaky ReLU |
|
| Hidden layers | Negative slope is a chosen hyperparameter |
Sigmoid acts independently on one or several logits for non-exclusive labels. Softmax normalises a vector into probabilities summing to 1 for mutually exclusive classes.
For the broader ANN route, Artificial Neural Networks: Complete Guide with Worked Examples for GATE and Interviews adds a sigmoid gradient update and parameter counting to the hard-step rule. Artificial Neural Networks Explained: Forward Pass, Worked Example and Exam Question Patterns then traces a full 2-2-1 forward pass through two hidden neurons and one output. The single-neuron comparison holds z=-0.6 fixed so five activation outputs can be compared directly.
6. Common traps and the correction for each
Switching signs silently:
w.x + bandw.x - thetaare equivalent only after writingb = -theta.Assuming the output at zero: copy the question's convention, or state your own if none is given.
Updating only the weights: when bias is trainable, update it with the same error term, as in the worked example.
Updating an already correct sample: calculate
t-yfirst. If it is zero, the perceptron update changes nothing.Calling a sigmoid score a class: a hard class still requires a stated decision threshold.
Rejecting ReLU because of its kink: optimisation systems use a defined subgradient convention at zero.
7. How exam questions turn these ideas into marks
Common question forms ask you to calculate z, perform one update, match an activation to its graph, identify linear separability, compare gradients, or distinguish sigmoid from softmax. These question forms do not establish official frequency.
Try three rapid checks:
For
z = 1.2, ReLU gives1.2because ReLU returns a positive input unchanged.If sigmoid output is
a = 0.8, its local derivative isa(1-a) = 0.8(0.2) = 0.16.The four XOR labels are not linearly separable because no one straight boundary can isolate the two positive points from the two negative points.
Use the UGC NET Computer Science High-Yield Topics article only as a broader revision map. For any exam-specific syllabus or current pattern, verify the details on the relevant conducting body's official website.
8. The short version and the next step
Calculate
zbefore applying the activation.State what happens at
z = 0.Keep bias and threshold signs consistent through
b = -theta.Compute
t-ybefore updating weights and bias.Remember that a single perceptron needs linearly separable data.
For a wider route through related learning, browse the Coding & Skill Development Courses. If you want a structured AI and machine-learning option, continue with AI & ML for Placements.
Finally, redo the worked example with target t = 0 under the same z >= 0 convention. The initial output is already 0, so t-y = 0 and no update occurs. Then sketch the four XOR points and try to draw one separating line. The failed sketch makes the limitation of a single perceptron visible.
Keep learning
Model Tracking: How to Record Experiments, Metrics and Artefacts
Build a reproducible model tracking record from one constructed churn experiment. Learn which fields, metrics, artefacts and promotion rules make a run trustworthy.
GATE DA Machine Learning Revision Map: From Probability to Neural-Network Calculations
Connect five machine-learning note sets through four worked problems and a complete neural-network forward pass, with a focused 90-minute revision loop.
Neural Network Architectures: Layers, Forward Passes and Worked Examples
Learn to read dense, convolutional and recurrent network diagrams as calculations. Count parameters, follow an exact 2-2-1 forward pass, and see what sharing changes.
Silhouette Score vs Inertia: Compare Clustering Quality with a Worked Example
Follow one dataset through two partitions to see why lower inertia and higher silhouette can support different choices, then learn how to compare them fairly.





