1. Gyanastra
  2. Artificial Intelligence
  3. Artificial Neural Networks
  4. Perceptron and Multilayer Networks
Free lesson, no account needed 12 min read 10 practice questions after it
Asked in past papers6 times
  • UGC NET201920172016201520132012

Artificial Intelligence · Artificial Neural Networks

Perceptron and Multilayer Networks

Overview

The perceptron is the fundamental building block of artificial neural networks: a single neuron that computes a weighted sum of inputs and applies a threshold.
Multilayer networks extend this by stacking layers of neurons with non-linear activation functions, enabling learning of complex non-linear decision boundaries.
This topic sits under Artificial Neural Networks in the UGC NET Computer Science syllabus. It requires basic understanding of vectors, weighted sums, step and sigmoid functions, and derivatives.
Mastery of these concepts is essential for questions on network architecture, learning rules, activation functions, and backpropagation.

Key concepts

  • Perceptron: A single neuron model with adjustable weights and bias. It takes input vector xx, computes net=∑wixi+b\text{net} = \sum w_i x_i + b (or net=∑wixi−θ\text{net} = \sum w_i x_i - \theta), and outputs f(net)f(\text{net}).
  • Bias (bb) / Threshold (θ\theta): Bias shifts the decision boundary. Often net=w⋅x−θ\text{net} = w \cdot x - \theta, so output =1= 1 if w⋅x≥θw \cdot x \ge \theta else 00. In some conventions b=−θb = -\theta, so net=w⋅x+b\text{net} = w \cdot x + b, output =1= 1 if net≥0\text{net} \ge 0.
  • Activation function: Non-linear function applied to net input. Step function (Heaviside): f(net)=1f(\text{net})=1 if net≥0\text{net} \ge 0 else 00. Sign function: f(net)=1f(\text{net})=1 if net≥0\text{net} \ge 0 else −1-1. Sigmoid (logistic): σ(net)=1/(1+e−net)\sigma(\text{net}) = 1/(1+e^{-\text{net}}), range (0,1)(0,1). Tanh: range (−1,1)(-1,1).
    ReLU: max⁡(0,net)\max(0, \text{net}).
  • Decision boundary: The set of points where w⋅x+b=0w \cdot x + b = 0. For a single perceptron, it is a linear hyperplane.
  • Linear separability: Two classes are linearly separable if there exists a hyperplane that separates them. A single-layer perceptron can solve only linearly separable problems. AND, OR are linearly separable; XOR is not.
  • Perceptron learning rule: For each training example (x,t)(x, t), compute y=f(net)y = f(\text{net}). If y≠ty \ne t, update wi←wi+η(t−y)xiw_i \leftarrow w_i + \eta (t - y) x_i and b←b+η(t−y)b \leftarrow b + \eta (t - y). η\eta is the learning rate.
    The algorithm stops after finite steps if the data is linearly separable (Perceptron Convergence Theorem).
  • Multilayer Perceptron (MLP): A feedforward network with an input layer, one or more hidden layers, and an output layer. Each layer has neurons with non-linear activations.
    MLPs can approximate any continuous function (Universal Approximation Theorem).
  • Backpropagation: Supervised learning algorithm for MLPs.
    It performs a forward pass to compute outputs, calculates the error, then propagates the error backward from output to input, computing gradients using the chain rule, and updates weights via gradient descent.
  • Delta rule: Also called Widrow–Hoff or LMS rule. For a linear neuron with squared error, wi←wi+η(t−y)xiw_i \leftarrow w_i + \eta (t - y) x_i. It is the basis for backpropagation.
  • Gradient descent: w←w−α∂E∂ww \leftarrow w - \alpha \frac{\partial E}{\partial w}, where α\alpha is learning rate, EE is error. The negative sign moves weights opposite to the gradient to minimize error.
  • Epoch: One full pass through the training set.
  • Learning rate (η\eta or α\alpha): Step size for weight updates. Too large may cause oscillation; too small slows convergence.

How it works

Perceptron computation and learning:

  1. Initialize weights and bias (often to small random values or zeros).
  2. For each training example (x,t)(x, t): a. Compute net input: net=∑wixi+b\text{net} = \sum w_i x_i + b. b. Apply activation: y=f(net)y = f(\text{net}). For binary classification, use step or sign. c. Compute error: e=t−ye = t - y. d. If e≠0e \ne 0, update weights: wi←wi+ηexiw_i \leftarrow w_i + \eta e x_i, and bias b←b+ηeb \leftarrow b + \eta e.
  3. Repeat for all examples (one epoch). If the dataset is linearly separable, the algorithm converges to a separating hyperplane in finite steps. If not, it may oscillate.

The update rule moves the decision boundary in the direction that reduces misclassification: if output is 0 but target is 1, weights increase for positive inputs and decrease for negative inputs, shifting the boundary to include the point.

Multilayer network and backpropagation:

  1. Architecture: Input layer (features), hidden layers (non-linear feature extraction), output layer (prediction). Each neuron in layer ll receives inputs from previous layer, computes net=∑wijyi+bj\text{net} = \sum w_{ij} y_i + b_j, applies activation yj=f(net)y_j = f(\text{net}).
  2. Forward pass: Feed input through the network layer by layer to compute final output.
  3. Compute error: For squared error, E=12∑k(tk−yk)2E = \frac{1}{2} \sum_k (t_k - y_k)^2 over output neurons kk.
  4. Backward pass: Compute delta for each neuron.
    • Output layer: δk=(tk−yk)f′(netk)\delta_k = (t_k - y_k) f'(\text{net}_k).
    • Hidden layer: δj=f′(netj)∑kδkwjk\delta_j = f'(\text{net}_j) \sum_k \delta_k w_{jk} (where kk ranges over neurons in the next layer).
  5. Update weights: wij←wij+ηδjyiw_{ij} \leftarrow w_{ij} + \eta \delta_j y_i, and bias bj←bj+ηδjb_j \leftarrow b_j + \eta \delta_j. (This corresponds to gradient descent: w←w−α∂E∂ww \leftarrow w - \alpha \frac{\partial E}{\partial w}, since ∂E∂wij=−δjyi\frac{\partial E}{\partial w_{ij}} = -\delta_j y_i.)
  6. Repeat for many epochs until error is minimized.

The chain rule is the core: the gradient of error with respect to a weight in an early layer depends on the deltas of all subsequent layers.

Decision boundary derivation: For a perceptron with net=w1x1+w2x2+b\text{net} = w_1 x_1 + w_2 x_2 + b, the boundary is w1x1+w2x2+b=0w_1 x_1 + w_2 x_2 + b = 0. Points with net>0\text{net} > 0 belong to one class, net<0\text{net} < 0 to the other.
To check if a line separates classes, plug each point into the line expression; all points of one class must give the same sign, and the other class the opposite sign.

Why XOR fails: XOR points (0,0)→0(0,0)\to0, (0,1)→1(0,1)\to1, (1,0)→1(1,0)\to1, (1,1)→0(1,1)\to0. No single straight line can separate the 1s from the 0s. A single perceptron can only draw one straight line. Adding a hidden layer allows the network to combine multiple linear boundaries into a non-linear one.

Figure. Each input feeds both hidden neurons, and both hidden neurons feed the output. The nearby text describes computing output deltas first, then hidden deltas, then updating weights and biases.

Formulas

  • Net input: net=∑i=1nwixi+b\text{net} = \sum_{i=1}^{n} w_i x_i + b (or ∑wixi−θ\sum w_i x_i - \theta).
  • Step activation: f(net)={1if net≥00if net<0f(\text{net}) = \begin{cases}1 & \text{if } \text{net} \ge 0 \\ 0 & \text{if } \text{net} < 0\end{cases} (or threshold θ\theta).
  • Sign activation: f(net)={1if net≥0−1if net<0f(\text{net}) = \begin{cases}1 & \text{if } \text{net} \ge 0 \\ -1 & \text{if } \text{net} < 0\end{cases}.
  • Sigmoid (logistic): σ(z)=11+e−z\sigma(z) = \frac{1}{1+e^{-z}}, derivative σ′(z)=σ(z)(1−σ(z))\sigma'(z) = \sigma(z)(1-\sigma(z)).
  • Scaled sigmoid: f(x)=11+e−kxf(x) = \frac{1}{1+e^{-kx}}, derivative f′(x)=kf(x)(1−f(x))f'(x) = k f(x)(1-f(x)). For k=2k=2, f′(0)=12f'(0) = \frac{1}{2}.
  • Perceptron weight update: wi(n+1)=wi(n)+η[t(n)−y(n)]xi(n)w_i(n+1) = w_i(n) + \eta [t(n) - y(n)] x_i(n); bias b(n+1)=b(n)+η[t(n)−y(n)]b(n+1) = b(n) + \eta [t(n) - y(n)].
  • Delta rule (LMS): wi←wi+η(t−y)xiw_i \leftarrow w_i + \eta (t - y) x_i.
  • Gradient descent: w←w−α∂E∂ww \leftarrow w - \alpha \frac{\partial E}{\partial w}.
  • Squared error: E=12∑k(tk−yk)2E = \frac{1}{2} \sum_k (t_k - y_k)^2.
  • Backprop output delta: δk=(tk−yk)f′(netk)\delta_k = (t_k - y_k) f'(\text{net}_k).
  • Backprop hidden delta: δj=f′(netj)∑kδkwjk\delta_j = f'(\text{net}_j) \sum_k \delta_k w_{jk}.
  • Backprop weight update: wij←wij+ηδjyiw_{ij} \leftarrow w_{ij} + \eta \delta_j y_i.
  • Decision boundary: w⋅x+b=0w \cdot x + b = 0.

Worked examples

Example 1 (Perceptron output): A perceptron has weights W1=−3.9W_1 = -3.9, W2=1.1W_2 = 1.1 and threshold T=0.3T = 0.3. Inputs are x1=1.3x_1 = 1.3, x2=2.2x_2 = 2.2. The output is 1 if ∑Wixi≥T\sum W_i x_i \ge T, else 0. Compute:
∑Wixi=(−3.9)(1.3)+(1.1)(2.2)=−5.07+2.42=−2.65\sum W_i x_i = (-3.9)(1.3) + (1.1)(2.2) = -5.07 + 2.42 = -2.65.
Since −2.65<0.3-2.65 < 0.3, output = 0. Answer: 0.

Example 2 (Weight update): A perceptron uses update rule wnew=wold+η(t−y)xw_{\text{new}} = w_{\text{old}} + \eta (t - y) x. Given wold=0.4w_{\text{old}} = 0.4, η=0.2\eta = 0.2, t=1t = 1, y=0y = 0, x=3x = 3. Compute error t−y=1−0=1t - y = 1 - 0 = 1. Update: wnew=0.4+0.2×1×3=0.4+0.6=1.0w_{\text{new}} = 0.4 + 0.2 \times 1 \times 3 = 0.4 + 0.6 = 1.0.

Example 3 (Decision boundary): Class C1C_1: (−1,−1),(−1,1),(1,−1)(-1,-1), (-1,1), (1,-1). Class C2C_2: (1,1)(1,1). Which line separates? Test x1+x2−0.5=0x_1 + x_2 - 0.5 = 0.
For C1C_1: (−1,−1)→−1−1−0.5=−2.5<0(-1,-1) \to -1-1-0.5 = -2.5 < 0; (−1,1)→−1+1−0.5=−0.5<0(-1,1) \to -1+1-0.5 = -0.5 < 0; (1,−1)→1−1−0.5=−0.5<0(1,-1) \to 1-1-0.5 = -0.5 < 0.
For C2C_2: (1,1)→1+1−0.5=1.5>0(1,1) \to 1+1-0.5 = 1.5 > 0. All C1C_1 on negative side, C2C_2 on positive side. So x1+x2−0.5=0x_1 + x_2 - 0.5 = 0 is the boundary.

Example 4 (Sigmoid derivative): Given f(x)=11+e−2xf(x) = \frac{1}{1+e^{-2x}}, find f′(0)f'(0). Rewrite as f(x)=(1+e−2x)−1f(x) = (1+e^{-2x})^{-1}. Derivative: f′(x)=−1(1+e−2x)−2⋅(−2e−2x)=2e−2x(1+e−2x)2f'(x) = -1(1+e^{-2x})^{-2} \cdot (-2e^{-2x}) = \frac{2e^{-2x}}{(1+e^{-2x})^2}. At x=0x=0: e0=1e^0 = 1, so f′(0)=2⋅1(1+1)2=24=12f'(0) = \frac{2 \cdot 1}{(1+1)^2} = \frac{2}{4} = \frac{1}{2}. Alternatively use f′(x)=2f(x)(1−f(x))f'(x) = 2 f(x)(1-f(x)); f(0)=1/2f(0)=1/2, so f′(0)=2(1/2)(1/2)=1/2f'(0)=2(1/2)(1/2)=1/2.

Example 5 (Backprop weight update): Consider a network with one input x=1x=1, one hidden neuron with weight w=0.5w=0.5 and bias b=0b=0, activation sigmoid f(z)=1/(1+e−z)f(z)=1/(1+e^{-z}). Output layer has one neuron with weight v=1.0v=1.0 and bias 00, also sigmoid.
Target t=1t=1. Learning rate η=0.1\eta=0.1. Compute one weight update for vv and ww.
Forward: hidden net z1=wx+b=0.5⋅1=0.5z_1 = w x + b = 0.5 \cdot 1 = 0.5. Hidden output h=σ(0.5)≈0.6225h = \sigma(0.5) \approx 0.6225. Output net z2=vh=1.0⋅0.6225=0.6225z_2 = v h = 1.0 \cdot 0.6225 = 0.6225. Output y=σ(0.6225)≈0.6508y = \sigma(0.6225) \approx 0.6508.
Error at output: E=12(t−y)2E = \frac{1}{2} (t-y)^2. Output delta: δ2=(t−y)f′(z2)=(1−0.6508)⋅y(1−y)=0.3492⋅0.6508⋅0.3492≈0.3492⋅0.2272≈0.0793\delta_2 = (t-y) f'(z_2) = (1-0.6508) \cdot y(1-y) = 0.3492 \cdot 0.6508 \cdot 0.3492 \approx 0.3492 \cdot 0.2272 \approx 0.0793.
Update vv: v←v+ηδ2h=1.0+0.1⋅0.0793⋅0.6225≈1.0+0.00494=1.00494v \leftarrow v + \eta \delta_2 h = 1.0 + 0.1 \cdot 0.0793 \cdot 0.6225 \approx 1.0 + 0.00494 = 1.00494.
Hidden delta: δ1=f′(z1)⋅δ2v=h(1−h)⋅δ2v=0.6225⋅0.3775⋅0.0793⋅1.0≈0.2350⋅0.0793≈0.01863\delta_1 = f'(z_1) \cdot \delta_2 v = h(1-h) \cdot \delta_2 v = 0.6225 \cdot 0.3775 \cdot 0.0793 \cdot 1.0 \approx 0.2350 \cdot 0.0793 \approx 0.01863.
Update ww: w←w+ηδ1x=0.5+0.1⋅0.01863⋅1=0.501863w \leftarrow w + \eta \delta_1 x = 0.5 + 0.1 \cdot 0.01863 \cdot 1 = 0.501863.

Comparison

FeatureSingle-Layer PerceptronMultilayer Perceptron (MLP)
LayersInput and output onlyInput, one or more hidden, output
ActivationTypically step or sign (linear threshold)Non-linear (sigmoid, tanh, ReLU)
Decision boundaryLinear hyperplaneNon-linear, complex
XOR problemCannot solveCan solve
Learning algorithmPerceptron ruleBackpropagation (gradient descent)
ConvergenceGuaranteed if linearly separableNo guarantee; may get stuck in local minima
ActivationFormulaRangeDerivativeTypical Use
Step11 if z≥0z \ge 0 else 00{0,1}\{0,1\}0 except undefined at 0Binary classification
Sign11 if z≥0z \ge 0 else −1-1{−1,1}\{-1,1\}0 except undefined at 0Binary classification
Sigmoid11+e−z\frac{1}{1+e^{-z}}(0,1)(0,1)σ(z)(1−σ(z))\sigma(z)(1-\sigma(z))Output probabilities, hidden layers
Tanhez−e−zez+e−z\frac{e^z - e^{-z}}{e^z + e^{-z}}(−1,1)(-1,1)1−tanh⁡2(z)1 - \tanh^2(z)Hidden layers
ReLUmax⁡(0,z)\max(0,z)[0,∞)[0,\infty)1 if z>0z>0, 0 if z<0z<0Deep networks
ConceptPerceptron RuleDelta Rule
Error signalt−yt - y where yy is threshold outputt−yt - y where yy is linear output
Updatewi←wi+η(t−y)xiw_i \leftarrow w_i + \eta (t-y) x_iwi←wi+η(t−y)xiw_i \leftarrow w_i + \eta (t-y) x_i
TargetBinary labelsContinuous or binary
BasisError correctionGradient descent on squared error

Revision summary

  • Single perceptron = linear classifier. Decision boundary is w⋅x+b=0w \cdot x + b = 0.
  • Perceptron update: w←w+η(t−y)xw \leftarrow w + \eta (t - y) x. Bias updates with η(t−y)\eta (t - y).
  • XOR is not linearly separable; AND, OR are.
  • Backpropagation direction: error propagates backward from output to input.
  • Sigmoid: 1/(1+e−z)1/(1+e^{-z}), derivative f(1−f)f(1-f). Scaled sigmoid 1/(1+e−kz)1/(1+e^{-kz}) has derivative kf(1−f)k f(1-f).
  • Gradient descent update: w←w−α∂E∂ww \leftarrow w - \alpha \frac{\partial E}{\partial w}.
  • Delta rule = Widrow–Hoff = LMS: adjusts weights by (t−y)x(t-y)x.
  • Perceptron convergence theorem: if linearly separable, converges in finite steps.
  • Hidden layers enable non-linear decision boundaries.
  • Learning rate η\eta controls step size; too large causes oscillation, too small slows convergence.
  • Sign activation outputs ±1\pm 1; step outputs 0/10/1.
  • Check bias sign carefully: w⋅x+b=0w \cdot x + b = 0 vs w⋅x−θ=0w \cdot x - \theta = 0.

Previous-year exam insights

  • Direct numeric computation: Given weights, threshold, inputs, compute perceptron output.
    Carefully apply the inequality (≥ vs >) and sign of bias/threshold.
  • Learning rule identification: Know the exact perceptron update rule with input vector xx and error (t−y)(t-y).
    Options often omit xx or use wrong sign.
  • Decision boundary testing: Given points and a candidate line, plug points into the line equation; all points of one class must have the same sign, and the other class the opposite sign.
    Traps: sign convention, arithmetic errors.
  • Activation function formulas and derivatives: Sigmoid formula and its derivative.
    For scaled sigmoid 1/(1+e−2x)1/(1+e^{-2x}), derivative at 0 is 1/2.
    Do not confuse with unscaled derivative (1/4).
  • Backpropagation direction: Weight changes propagate backward from sink (output) to source (input).
    Understand forward pass computes outputs, backward pass computes gradients.
  • Linear separability: Identify which Boolean functions (AND, OR, XOR) a single-layer perceptron can solve.
    XOR requires hidden layer or RBF.
  • Gradient descent sign: Weight update is w−α∂E∂ww - \alpha \frac{\partial E}{\partial w} (minus sign) to minimize error.
  • Match-the-list: Match perceptron, hidden layer, backpropagation, linear separability with their definitions/properties.
    Read each term carefully.

Practice at PARIKSHA

You are ready for the PARIKSHA tests of this sub-topic when you can:

  1. Compute the output of a single perceptron given weights, bias/threshold, and inputs, using both step and sign activations.
  2. Apply the perceptron learning rule to update weights for a misclassified example.
  3. Determine whether a given set of 2D points is linearly separable and find a separating line.
  4. Explain why XOR cannot be solved by a single-layer perceptron but can be solved by a multilayer network.
  5. Write the formula and derivative of the sigmoid function, including scaled versions.
  6. Describe the forward pass and backward pass in backpropagation and write the delta formulas for output and hidden layers.
  7. Distinguish between the perceptron rule and the delta rule.
  8. State the perceptron convergence theorem and its condition.
  9. Identify the role of hidden layers and non-linear activation functions in MLPs.
  10. Match terms like perceptron, linear separability, backpropagation, and gradient descent with their correct descriptions.

Attempt the sub-topic test first, then the subject test.

Pages 1–2 of 2