Perceptron

GATE Relevance: High

Prerequisites

🎯 Learning Objectives

  • Write the perceptron model: y = sign(w·x + b)
  • Implement the perceptron learning rule
  • State and understand the Perceptron Convergence Theorem
  • Explain linear separability and the XOR problem
  • Compute the decision boundary equation for 2D inputs
  • Work through complete numerical examples suitable for GATE

1. Rosenblatt’s Perceptron (1958)

Frank Rosenblatt proposed the Perceptron as the first algorithm that could learn weights from data. Unlike the McCulloch-Pitts model, the perceptron has an automatic learning rule that adjusts weights based on errors.

Perceptron Model

Given input vector x = (x1, x2, …, xn), weight vector w = (w1, w2, …, wn), and bias b:

z = w1x1 + w2x2 + … + wnxn + b = w·x + b

y = sign(z) = { +1  if z ≥ 0
              { −1  if z < 0

The output is a binary classification: +1 or −1.

Alternative Convention

Some textbooks use y ∈ {0, 1} with a step function instead of sign. For GATE, the sign convention with ±1 is more common in perceptron contexts.

2. Perceptron Learning Rule

The perceptron learns by iteratively updating weights whenever it makes a misclassification.

Perceptron Learning Algorithm

Initialize: w = 0 (or small random), b = 0, learning rate η > 0
Repeat until convergence (no errors on training set):
    For each training sample (x(i), t(i)):
        Compute prediction: y(i) = sign(w·x(i) + b)
        If y(i) ≠ t(i):  (misclassification)
            w ← w + η · t(i) · x(i)
            b ← b + η · t(i)

Intuition: When the perceptron predicts wrong, the update rule pushes the weight vector toward the correct class direction. If the target is +1 but we predicted −1, we add the input vector to the weights (moving the boundary to include the misclassified point).

Learning Rate η

For the basic perceptron, η = 1 works fine because the sign function only cares about the direction of w, not its magnitude. Scaling η just scales the entire weight vector, which doesn’t change the decision boundary. However, η is kept for generality.

3. Perceptron Convergence Theorem

Perceptron Convergence Theorem (Novikoff, 1962)

If the training data is linearly separable, the perceptron learning algorithm will converge to a set of weights that correctly classifies all training points in a finite number of steps.

Specifically, if there exists a weight vector w* with ‖w*‖ = 1 and margin γ = mini t(i)(w*·x(i)) > 0, and R = maxi ‖x(i)‖, then the number of updates is at most (R/γ)2.

Critical Limitation

If the data is NOT linearly separable, the perceptron algorithm will never converge — it will oscillate forever, never finding a perfect boundary. This is why the XOR problem was so devastating.

4. Linear Separability & Decision Boundary

Linear Separability

Two classes of points in ℝn are linearly separable if there exists a hyperplane w·x + b = 0 that perfectly separates all positive examples from all negative examples.

For 2D inputs (x1, x2), the decision boundary is a line:

w1x1 + w2x2 + b = 0
⇒ x2 = −(w1/w2)x1 − b/w2

This is a line with slope −w1/w2 and intercept −b/w2.

Example: Decision Boundary

Given w = (2, 3), b = −6. The decision boundary is:

2x1 + 3x2 − 6 = 0 ⇒ x2 = −(2/3)x1 + 2

Points above this line (where 2x1 + 3x2 − 6 > 0) are classified as +1; points below as −1.

5. The XOR Problem

The XOR (exclusive-or) function was the critical challenge that proved single-layer perceptrons have fundamental limitations.

x1x2XOR Output
000 (−1)
011 (+1)
101 (+1)
110 (−1)

If you plot these four points in 2D, the positive points (0,1) and (1,0) are on opposite corners, and the negative points (0,0) and (1,1) are on the other diagonal. No single straight line can separate them.

Minsky & Papert (1969)

In their book Perceptrons, Minsky and Papert formally proved that a single-layer perceptron cannot compute XOR or any function that is not linearly separable. This result caused widespread pessimism about neural networks and contributed to the first “AI winter” in neural network research.

Solution: Multi-Layer Networks

XOR can be solved by combining two perceptrons in a hidden layer: one computes (x1 AND NOT x2) and the other computes (NOT x1 AND x2); an output neuron then computes OR of these two hidden outputs. This is a 2-layer network — the topic of the next page.

6. Complete Numerical Example (GATE-Style)

Problem

Train a perceptron with η = 1 to learn the AND function. Inputs are (0,0), (0,1), (1,0), (1,1) with labels −1, −1, −1, +1 respectively. Start with w1=0, w2=0, b=0.

Solution: Step-by-Step

Epoch 1:

  • Sample (0,0), t=−1: z = 0·0 + 0·0 + 0 = 0 ⇒ y = sign(0) = +1. Misclassified!
    Update: w1 = 0 + 1·(−1)·0 = 0, w2 = 0 + 1·(−1)·0 = 0, b = 0 + 1·(−1) = −1
  • Sample (0,1), t=−1: z = 0·0 + 0·1 + (−1) = −1 ⇒ y = sign(−1) = −1. Correct!
  • Sample (1,0), t=−1: z = 0·1 + 0·0 + (−1) = −1 ⇒ y = −1. Correct!
  • Sample (1,1), t=+1: z = 0·1 + 0·1 + (−1) = −1 ⇒ y = −1. Misclassified!
    Update: w1 = 0 + 1·(+1)·1 = 1, w2 = 0 + 1·(+1)·1 = 1, b = −1 + 1·(+1) = 0

After Epoch 1: w = (1, 1), b = 0

Epoch 2:

  • Sample (0,0), t=−1: z = 1·0 + 1·0 + 0 = 0 ⇒ y = +1. Misclassified!
    Update: w1 = 1, w2 = 1, b = 0 + (−1) = −1
  • Sample (0,1), t=−1: z = 1·0 + 1·1 + (−1) = 0 ⇒ y = +1. Misclassified!
    Update: w1 = 1, w2 = 1 + (−1)·1 = 0, b = −1 + (−1) = −2
  • Sample (1,0), t=−1: z = 1·1 + 0·0 + (−2) = −1 ⇒ y = −1. Correct!
  • Sample (1,1), t=+1: z = 1·1 + 0·1 + (−2) = −1 ⇒ y = −1. Misclassified!
    Update: w1 = 1 + 1 = 2, w2 = 0 + 1 = 1, b = −2 + 1 = −1

After Epoch 2: w = (2, 1), b = −1

Epoch 3:

  • Sample (0,0), t=−1: z = −1 ⇒ y = −1. Correct!
  • Sample (0,1), t=−1: z = 0 + 1 − 1 = 0 ⇒ y = +1. Misclassified!
    Update: w1 = 2, w2 = 1 + (−1)·1 = 0, b = −1 + (−1) = −2
  • Sample (1,0), t=−1: z = 2·1 + 0 − 2 = 0 ⇒ y = +1. Misclassified!
    Update: w1 = 2 + (−1)·1 = 1, w2 = 0, b = −2 + (−1) = −3
  • Sample (1,1), t=+1: z = 1 + 0 − 3 = −2 ⇒ y = −1. Misclassified!
    Update: w1 = 1 + 1 = 2, w2 = 0 + 1 = 1, b = −3 + 1 = −2

After Epoch 3: w = (2, 1), b = −2

Epoch 4:

  • (0,0): z = −2 ⇒ y = −1. Correct ✓
  • (0,1): z = 0 + 1 − 2 = −1 ⇒ y = −1. Correct ✓
  • (1,0): z = 2 + 0 − 2 = 0 ⇒ y = +1. Misclassified!
    Update: w1 = 2 − 1 = 1, w2 = 1, b = −2 − 1 = −3
  • (1,1): z = 1 + 1 − 3 = −1 ⇒ y = −1. Misclassified!
    Update: w1 = 1 + 1 = 2, w2 = 1 + 1 = 2, b = −3 + 1 = −2

After Epoch 4: w = (2, 2), b = −2. Testing: (0,0)→−2 (−1 ✓), (0,1)→0 (+1 ✗). Continue training…

Eventually the algorithm converges (AND is linearly separable). A valid solution is w = (1, 1), b = −1.5 which gives: z = x1 + x2 − 1.5. Only (1,1) yields z = 0.5 > 0.

7. GATE-Style Problems

GATE Problem: Decision Boundary

Q: A perceptron has weights w1 = 3, w2 = −2 and bias b = 6. What is the equation of the decision boundary? Classify point (4, 5).

A: Decision boundary: 3x1 − 2x2 + 6 = 0 ⇒ x2 = (3/2)x1 + 3.

For (4, 5): z = 3(4) − 2(5) + 6 = 12 − 10 + 6 = 8 > 0 ⇒ class +1.

GATE Problem: Boolean Functions

Q: Which of the following Boolean functions can a single perceptron compute? (i) AND (ii) OR (iii) NAND (iv) XOR

A: A single perceptron can compute AND, OR, and NAND (all linearly separable). It cannot compute XOR (not linearly separable).

Summary

  • The Perceptron computes y = sign(w·x + b) for binary classification.
  • The learning rule updates weights on misclassification: w ← w + η·t·x.
  • The Convergence Theorem guarantees finite convergence if and only if data is linearly separable.
  • The XOR problem cannot be solved by a single perceptron — need multi-layer networks.
  • Decision boundary in 2D: w1x1 + w2x2 + b = 0 is a straight line.
  • For GATE: be prepared to trace the learning algorithm step by step and compute decision boundaries.