Multi-layer perceptron and feed-forward neural networks
From the single perceptron to multi-layer feed-forward networks: activation functions, parameter counts, the forward pass, loss functions and training by backpropagation and gradient descent. GATE asks forward-pass and gradient numericals, parameter counts and XOR-type questions.
Each layer computes ; the weight matrix shape gives the parameter count.
Concept notes
1. The perceptron and linear separability
A perceptron computes a weighted sum and applies a step (threshold) function:
y^={10if w⊤x+b≥0otherwise
Its decision boundary is a hyperplane, so it can only separate linearly separable classes.
Perceptron learning rule: for each training point, and . A correctly classified point causes no change.
Convergence theorem: if the data is linearly separable, the rule finds a separating hyperplane in a finite number of updates. If it is not separable, the weights never settle.
AND, OR and NOT are linearly separable, so one perceptron can compute each. XOR is not: the points (0,1) and (1,0) (output 1) cannot be split from (0,0) and (1,1) (output 0) by one line. A hidden layer solves this.
2. Multi-layer feed-forward networks
A multi-layer perceptron (MLP) has an input layer, one or more hidden layers and an output layer. It is feed-forward: connections go only from one layer to the next, with no cycles. In a fully connected layer every neuron receives every output of the previous layer.
Layer computes
with . If layer has neurons, is and has entries.
Parameter count: (weights plus one bias per neuron). The input layer has no parameters.
Universal approximation: one hidden layer with enough neurons and a non-linear activation can approximate any continuous function on a bounded region as closely as needed. Deeper networks often need far fewer neurons for the same function.
A 2-3-1 feed-forward network: 2×3 + 3 = 9 parameters in the hidden layer and 3×1 + 1 = 4 at the output, 13 in total
3. Activation functions
Activation
Range
Sigmoid
, at most
tanh
, at most 1
ReLU
1 if , 0 if
Linear
all reals
1
Softmax turns the output scores into class probabilities: ; outputs are positive and sum to 1.
Key facts:
Non-linearity is essential. If every layer is linear, the whole network is , a single linear map, no matter how many layers.
, so tanh is a scaled, zero-centred sigmoid.
Sigmoid and tanh saturate: for large the derivative is near 0, so gradients vanish. ReLU does not saturate for , which is why it is the default in hidden layers.
Output layer: linear for regression, sigmoid for binary classification, softmax for multi-class.
4. Loss functions and gradient descent
Training minimises a loss over the training set by adjusting all weights and biases.
Regression: squared error (the only tidies the derivative).
Binary classification: cross-entropy with a sigmoid output.
Multi-class: for the true class , with a softmax output.
Gradient descent update with learning rate : .
Batch: gradient over the whole training set per step.
Stochastic (SGD): one example per step; noisy but cheap.
Mini-batch: a small batch per step; the usual choice.
A too-large makes the loss oscillate or diverge; a too-small makes training slow. The loss of a network with hidden layers is not convex, so gradient descent may stop at a local minimum or saddle point.
Do not initialise all weights to the same value (for example 0): every hidden neuron then computes the same output and gets the same gradient, so they stay identical (the symmetry problem). Use small random values.
5. Backpropagation
Backpropagation computes for every weight with the chain rule, working backwards from the output. Define the error of layer as .
Forward pass: compute and store every and .
Output error: .
Squared error with sigmoid output: .
Cross-entropy with sigmoid, or with softmax: (the derivatives cancel neatly).
Propagate back: .
Gradients: and .
So the gradient for the weight from neuron to neuron is (error at ) × (activation of ).
Vanishing gradients: each layer multiplies the error by . With sigmoid, , so after layers the factor is at most and early layers barely learn. ReLU, careful initialisation and normalisation reduce this.
Formulas to remember
Layer computation
Parameter count = number of inputs
Perceptron rule
Sigmoid derivative
Softmax
Cross-entropy loss
Gradient descent
Backpropagated errorWeight gradient
Common mistakes
Forgetting the biases when counting parameters: each neuron adds one.
Counting parameters for the input layer; it has none.
Applying the activation to the output when the question says the output is linear.
Writing the perceptron update with the wrong sign: it is , while gradient descent is .
Using for squared error with a sigmoid output; that shortcut holds for cross-entropy, while squared error keeps the factor .
Initialising all weights to zero, which keeps every hidden neuron identical.
Worked examples
Try each step yourself, then reveal the working.
Example 1: Counting parameters
numerical
A fully connected network has 4 inputs, one hidden layer of 5 neurons and 3 output neurons. Every neuron has a bias. How many trainable parameters are there?
Step 1: Count the hidden layer's weights and biases.
10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE DA syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.