Neural networks: perceptron, MLP and backpropagation
GATE DA150 min read
The single neuron
Definition. A neuron computes a weighted sum of its inputs plus a bias, then applies an activation function :
- With the neuron is linear regression.
- With (sigmoid) and cross-entropy loss it is logistic regression.
- With a step function it is the perceptron.
So the familiar linear models are one-neuron networks. Neural networks gain power by stacking many neurons with non-linear activations.
Geometry. The set is a hyperplane. The vector is perpendicular to it, and the distance from the origin to the plane is . A single neuron with a step or sigmoid activation can therefore only separate classes with a straight boundary.
The perceptron and its learning rule
Model. if , otherwise .
Learning rule (for one example at a time, learning rate ):
When the prediction is right, and nothing changes. A missed positive adds to ; a false positive subtracts it.
Perceptron convergence theorem. If the data is linearly separable, the rule reaches a separating hyperplane after finitely many updates. Suppose every point satisfies and some unit vector separates the data with margin . Then the number of mistakes is at most . If the data is not separable, the rule never settles.
Solved example: learning AND
Example 1. Train on AND with , and , visiting the points in the order . The target is 1 only for . Each row shows the point, the score , the prediction, and the weights after the step.
| Epoch | Point | New | New | |||
|---|---|---|---|---|---|---|
| 1 | (1,1) | 0 | 0 | 1 | (1, 1) | 1 |
| 2 | (0,0) | 1 | 1 | 0 | (1, 1) | 0 |
| 2 | (0,1) | 1 | 1 | 0 | (1, 0) | −1 |
| 2 | (1,1) | 0 | 0 | 1 | (2, 1) | 0 |
| 3 | (0,1) | 1 | 1 | 0 | (2, 0) | −1 |
| 3 | (1,0) | 1 | 1 | 0 | (1, 0) | −2 |
| 3 | (1,1) | −1 | 0 | 1 | (2, 1) | −1 |
| 4 | (1,0) | 1 | 1 | 0 | (1, 1) | −2 |
| 4 | (1,1) | 0 | 0 | 1 | (2, 2) | −1 |
| 5 | (0,1) | 1 | 1 | 0 | (2, 1) | −2 |
The table lists only the steps that made a mistake. In epoch 6 every point is correct: the scores are , so only has . The perceptron has learned AND with and .
What one perceptron cannot do
XOR outputs 1 for and only. Suppose a line separated it. Then:
- , from ;
- and ;
- .
Adding the two middle inequalities gives . So , which contradicts the last line. No single perceptron computes XOR. This was the classic argument (Minsky and Papert, 1969) that motivated hidden layers.
Activation functions
| Name | Range | Notes | ||
|---|---|---|---|---|
| Step | 1 if , else 0 | 0 (undefined at 0) | {0, 1} | no useful gradient |
| Sigmoid | (0, 1) | max slope 0.25 at | ||
| Tanh | (−1, 1) | zero-centred; slope 1 at 0 | ||
| ReLU | 1 if , 0 if | cheap; can "die" | ||
| Leaky ReLU | if , else | 1 or | keeps a small gradient | |
| Linear | 1 | used at regression outputs |
Useful identities.
- .
- .
- and .
- and .
Example 2: derivative values. At : , so . At : , so . A saturated sigmoid passes back almost no gradient.
Dying ReLU. If a ReLU unit's input is negative for every training example, its gradient is always 0 and it never recovers. Leaky ReLU and careful learning rates prevent this.
Output layers and losses
| Task | Output activation | Loss |
|---|---|---|
| Regression | linear | squared error |
| Binary classification | sigmoid | binary cross-entropy |
| -class classification | softmax | cross-entropy |
Softmax. . The outputs are positive and sum to 1. Adding the same constant to every leaves them unchanged, and implementations subtract for numerical safety.
You have read the free 30% of this note
Sign in with Google to keep reading. It is free, takes one tap, and you also get:
- 8 practice questions from this note
- Every note in full, plus the PDF library
- Official past papers as timed tests, with explanations
- An AI tutor for doubts, in Hindi or English
- Your progress, mistakes and study plan saved on every device