XOR problem- how it is solved using multi layer perceptron

 

πŸ”Ή What is the XOR Problem?

1. 🧠 Definition

The XOR (Exclusive OR) function outputs:

  • 1 when inputs are different
  • 0 when inputs are same

Truth Table:

x₁    x₂    XOR Output
0    0    0
0    1    1
1    0    1
1    1    0

2. ❌ Why is XOR a Problem for Perceptron?

A single-layer perceptron can only learn linear decision boundaries (straight lines).

XOR is not linearly separable:

  • No single straight line can separate:
    • (0,1) and (1,0) → class 1
    • (0,0) and (1,1) → class 0

➡️ This limitation is called the XOR problem.




3. πŸ“ Geometric Intuition

  • Points lie diagonally:
    • Class 1 → opposite corners
    • Class 0 → opposite corners

➡️ Requires non-linear separation




πŸ”Ή Solution: Multi-Layer Perceptron (MLP)

4. 🧩 Key Idea

Add a hidden layer to:

  • Transform input space
  • Create non-linear decision boundaries

5. πŸ—️ Network Architecture

A simple MLP for XOR:

  • Input layer: 2 neurons (x₁, x₂)
  • Hidden layer: 2 neurons
  • Output layer: 1 neuron


6. ⚙️ How It Works

Step 1: Hidden Layer creates intermediate features

Each hidden neuron acts like a linear classifier.

Example:

  • Hidden neuron 1 → detects (x₁ OR x₂)
  • Hidden neuron 2 → detects (x₁ AND x₂)

Step 2: Output Layer combines them

Final output:

XOR=(OR)AND (NAND)\text{XOR} = (\text{OR}) - (\text{AND})XOR=(x1x2)¬(x1x2)

➡️ Produces correct XOR behavior.


7. πŸ”’ Mathematical View

Hidden layer:

h1=step(x1+x20.5)(OR)h_1 = \text{step}(x_1 + x_2 - 0.5) \quad (\text{OR})
h2=step(-x1-x2+1.5)(NAND)h_2 = \text{step}(x_1 + x_2 - 1.5) \quad (\text{AND})

Output layer:

y=step(h1+h21.5) ( AND )y = \text{step}(h_1 - h_2 - 0.5)








8. 🎯 Key Insight

The hidden layer transforms the data into a space where it becomes linearly separable.


9. 🧠 Why This Matters

  • Solving XOR showed that:
    • Single-layer networks are limited
    • Multi-layer networks are powerful

➡️ This led to the development of multi layer neural netwok and deep learning


πŸ”Ή One-Line Summary

The XOR problem shows that single-layer perceptrons cannot model non-linear patterns, but multi-layer perceptrons solve it by introducing hidden layers that enable non-linear decision boundaries.

Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Unsupervised Learning