Multi-Layer Perceptrons and Feed-Forward Neural Networks
The perceptron and its learning rule, linear separability and the XOR problem, multi-layer feed-forward networks, activation functions, the forward pass and output layers (linear, sigmoid, softmax) with matching losses, backpropagation via the chain rule, training with (stochastic) gradient descent, counting parameters, the universal approximation theorem, vanishing gradients, initialisation and regularisation.
A single artificial neuron computes a weighted sum and thresholds it:
y^=sign(w⊤x+b).
Perceptron learning rule (labels ±1): for each misclassified example, w←w+ηyx, b←b+ηy.
Convergence theorem: if the data is linearly separable, the rule finds a separating hyperplane in a finite number of updates (at most (R/γ)2 for data radius R and margin γ).
If the data is not separable (e.g. XOR), it never converges.
Minsky and Papert's observation: one layer cannot represent XOR; two can.
Multi-layer feed-forward networks
A multi-layer perceptron (MLP) stacks layers of neurons; information flows forward from inputs through hidden layers to outputs, with no cycles:
Parameter count for layer sizes n0,n1,…,nL: ∑ℓ=1L(nℓ−1nℓ+nℓ).
Activation functions
Activation
g(z)
g′(z)
Notes
Sigmoid
1+e−z1
g(1−g)≤0.25
outputs in (0,1); saturates → vanishing gradients
tanh
ez+e−zez−e−z
1−g2≤1
zero-centred; still saturates
ReLU
max(0,z)
0 or 1
default for hidden layers; cheap; "dying" units
Leaky ReLU
max(αz,z)
α or 1
keeps a small gradient for z<0
Step (perceptron)
[z>0]
0 almost everywhere
not trainable by gradients
Without non-linear activations, any depth collapses to a single linear map.
Output layers and losses
Task
Output activation
Loss
Regression
linear (identity)
mean squared error
Binary classification
sigmoid
binary cross-entropy
Multi-class classification
softmax ∑jezjezk
categorical cross-entropy −logy^true
With softmax + cross-entropy (or sigmoid + binary cross-entropy), the gradient at the output pre-activations is simply y^−y.
Backpropagation
Training minimises the loss by gradient descent; backpropagation computes all gradients efficiently by applying the chain rule backwards through the network, reusing intermediate results.
For layer ℓ with pre-activation z(ℓ)=W(ℓ)a(ℓ−1)+b(ℓ) and activation a(ℓ)=g(z(ℓ)):
Cost: one forward pass plus one backward pass, both about the same as a single evaluation of the network.
Training
Gradient descentθ←θ−η∇L; stochastic/mini-batch versions use a random batch per step (an epoch is one pass over the data).
Improvements: momentum, RMSProp, Adam (adaptive per-parameter step sizes); learning-rate schedules.
Initialisation matters: all-zero weights make hidden units identical (symmetry is never broken); use small random weights scaled to the layer size (Xavier/Glorot for tanh, He for ReLU).
The loss is non-convex, but in practice SGD finds good solutions.
weight decay (L2), dropout (randomly zero units during training), early stopping on validation loss, data augmentation, more data
Slow convergence
input normalisation, Adam, batch normalisation
Expressive power
Universal approximation theorem: a feed-forward network with a single hidden layer of sufficiently many units and a non-polynomial activation can approximate any continuous function on a compact set to arbitrary accuracy. Depth makes many functions far more parameter-efficient to represent.
Quick revision
Practice questions
GATE-style questions: 4 one-mark and 6 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.
Q1NAT1 mark
A fully connected network has 4 inputs, one hidden layer of 5 neurons and 3 outputs, with a bias for every hidden and output neuron. The total number of trainable parameters is ______.
Q2NAT2 marks
A network has inputs x1=1, x2=2; two ReLU hidden units h1=ReLU(x1−x2) and h2=ReLU(2x1+x2−1); and a linear output y=2h1+0.5h2+1. The output y is ______.
Q3MCQ1 mark
A single-layer perceptron (one linear threshold unit) cannot learn which Boolean function of two inputs?
Q4NAT2 marks
A perceptron with w=(0,0), b=0 predicts sign(w⊤x+b) with sign(0)=−1. It sees x=(1,2) with label y=+1 and applies the update w←w+ηyx, b←b+ηy with η=1. The new value of w2 is ______.
Q5MSQ2 marks
Which statements about feed-forward neural networks are correct?
One or more options are correct.
Q6NAT2 marks
A single sigmoid neuron computes y=σ(wx) with squared loss L=21(y−t)2. With w=0, x=2 and target t=1, the gradient ∂L/∂w is ______.
Q7MCQ2 marks
With step activations, hidden units h1=[x1+x2−0.5>0] (OR) and h2=[x1+x2−1.5>0] (AND), which output unit computes XOR of the binary inputs x1,x2?
Q8NAT2 marks
The softmax output for the logits (2,1,0) assigns probability ______ to the first class (round to two decimals).
Q9MCQ1 mark
The derivative of the ReLU activation max(0,z) for z>0 is
Q10NAT1 mark
A training set of 10,000 examples is processed with mini-batches of 100. The number of parameter updates (iterations) per epoch is ______.