∑GATE DA Atlas

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.

Section 610 practice questions

The perceptron

A single artificial neuron computes a weighted sum and thresholds it:

y^=sign⁡(w⊤x+b).\hat y = \operatorname{sign}(\mathbf w^\top\mathbf x + b).

Perceptron learning rule (labels ±1\pm1): for each misclassified example, w←w+η y x\mathbf w \leftarrow \mathbf w + \eta\,y\,\mathbf x, b←b+η yb \leftarrow b + \eta\,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(R/\gamma)^2 for data radius RR and margin γ\gamma).
  • If the data is not separable (e.g. XOR), it never converges.
0101 XOR green = 1 at (0,1), (1,0)red = 0 at (0,0), (1,1) no single line separates green from red,but a hidden layer computing OR and AND does:XOR = OR ∧ ¬AND
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:

h(1)=g(W(1)x+b(1)),h(ℓ)=g(W(ℓ)h(ℓ−1)+b(ℓ)),y^=o(W(L)h(L−1)+b(L)).\mathbf h^{(1)} = g\big(W^{(1)}\mathbf x + \mathbf b^{(1)}\big), \quad \mathbf h^{(\ell)} = g\big(W^{(\ell)}\mathbf h^{(\ell - 1)} + \mathbf b^{(\ell)}\big), \quad \hat{\mathbf y} = o\big(W^{(L)}\mathbf h^{(L-1)} + \mathbf b^{(L)}\big).
input (3)hidden (4): h = g(W₁x + b₁)output (2) ŷ = o(W₂h + b₂)
A 3–4–2 network: (3·4 + 4) + (4·2 + 2) = 26 parameters.

Parameter count for layer sizes n0,n1,…,nLn_0, n_1, \dots, n_L: ∑ℓ=1L(nℓ−1nℓ+nℓ)\sum_{\ell=1}^L(n_{\ell-1}n_\ell + n_\ell).

Activation functions

Activationg(z)g(z)g′(z)g'(z)Notes
Sigmoid11+e−z\frac{1}{1 + e^{-z}}g(1−g)≤0.25g(1 - g) \le 0.25outputs in (0,1)(0,1); saturates → vanishing gradients
tanhez−e−zez+e−z\frac{e^z - e^{-z}}{e^z + e^{-z}}1−g2≤11 - g^2 \le 1zero-centred; still saturates
ReLUmax⁡(0,z)\max(0, z)0 or 1default for hidden layers; cheap; "dying" units
Leaky ReLUmax⁡(αz,z)\max(\alpha z, z)α\alpha or 1keeps a small gradient for z<0z < 0
Step (perceptron)[z>0][z > 0]0 almost everywherenot trainable by gradients

Without non-linear activations, any depth collapses to a single linear map.

Output layers and losses

TaskOutput activationLoss
Regressionlinear (identity)mean squared error
Binary classificationsigmoidbinary cross-entropy
Multi-class classificationsoftmax ezk∑jezj\frac{e^{z_k}}{\sum_je^{z_j}}categorical cross-entropy −log⁡y^true-\log\hat y_{\text{true}}

With softmax + cross-entropy (or sigmoid + binary cross-entropy), the gradient at the output pre-activations is simply y^−y\hat{\mathbf y} - \mathbf 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 ℓ\ell with pre-activation z(ℓ)=W(ℓ)a(ℓ−1)+b(ℓ)\mathbf z^{(\ell)} = W^{(\ell)}\mathbf a^{(\ell-1)} + \mathbf b^{(\ell)} and activation a(ℓ)=g(z(ℓ))\mathbf a^{(\ell)} = g(\mathbf z^{(\ell)}):

δ(L)=∇a(L)L⊙o′(z(L)),δ(ℓ)=(W(ℓ+1)⊤δ(ℓ+1))⊙g′(z(ℓ)),\boldsymbol\delta^{(L)} = \nabla_{\mathbf a^{(L)}}\mathcal L \odot o'(\mathbf z^{(L)}), \qquad \boldsymbol\delta^{(\ell)} = \big(W^{(\ell+1)\top}\boldsymbol\delta^{(\ell+1)}\big)\odot g'(\mathbf z^{(\ell)}), ∂L∂W(ℓ)=δ(ℓ) a(ℓ−1)⊤,∂L∂b(ℓ)=δ(ℓ).\frac{\partial\mathcal L}{\partial W^{(\ell)}} = \boldsymbol\delta^{(\ell)}\,\mathbf a^{(\ell-1)\top}, \qquad \frac{\partial\mathcal L}{\partial\mathbf b^{(\ell)}} = \boldsymbol\delta^{(\ell)}.

Cost: one forward pass plus one backward pass, both about the same as a single evaluation of the network.

Training

  • Gradient descent θ←θ−η∇L\boldsymbol\theta \leftarrow \boldsymbol\theta - \eta\nabla\mathcal 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.

Problems and remedies

ProblemRemedy
Vanishing gradients (deep sigmoid/tanh nets)ReLU, careful initialisation, batch normalisation, residual connections
Exploding gradientsgradient clipping, smaller learning rate
Overfittingweight decay (L2), dropout (randomly zero units during training), early stopping on validation loss, data augmentation, more data
Slow convergenceinput 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=1x_1 = 1, x2=2x_2 = 2; two ReLU hidden units h1=ReLU(x1−x2)h_1 = \text{ReLU}(x_1 - x_2) and h2=ReLU(2x1+x2−1)h_2 = \text{ReLU}(2x_1 + x_2 - 1); and a linear output y=2h1+0.5h2+1y = 2h_1 + 0.5h_2 + 1. The output yy 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)\mathbf w = (0, 0), b=0b = 0 predicts sign⁡(w⊤x+b)\operatorname{sign}(\mathbf w^\top\mathbf x + b) with sign⁡(0)=−1\operatorname{sign}(0) = -1. It sees x=(1,2)\mathbf x = (1, 2) with label y=+1y = +1 and applies the update w←w+ηyx\mathbf w \leftarrow \mathbf w + \eta y\mathbf x, b←b+ηyb \leftarrow b + \eta y with η=1\eta = 1. The new value of w2w_2 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)y = \sigma(wx) with squared loss L=12(y−t)2L = \frac12(y - t)^2. With w=0w = 0, x=2x = 2 and target t=1t = 1, the gradient ∂L/∂w\partial L/\partial w is ______.

Q7MCQ2 marks

With step activations, hidden units h1=[x1+x2−0.5>0]h_1 = [x_1 + x_2 - 0.5 > 0] (OR) and h2=[x1+x2−1.5>0]h_2 = [x_1 + x_2 - 1.5 > 0] (AND), which output unit computes XOR of the binary inputs x1,x2x_1, x_2?

Q8NAT2 marks

The softmax output for the logits (2,1,0)(2, 1, 0) assigns probability ______ to the first class (round to two decimals).

Q9MCQ1 mark

The derivative of the ReLU activation max⁡(0,z)\max(0, z) for z>0z > 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 ______.