Perceptron
Imagine a simple voting committee with three members. Each member has a different amount of influence (weight). Member A's vote counts double, Member B's vote counts triple, and Member C's vote counts once. They each cast a vote (1 for yes, 0 for no), you multiply each vote by their weight, add it all up, and if the total exceeds a threshold β the proposal passes.
That's a perceptron. It's the simplest possible neural network β just one single neuron. It takes inputs, multiplies each by a weight, sums them up, and if the sum crosses a threshold, it fires (outputs 1). Otherwise, it stays quiet (outputs 0).
The math: dead simple
Here's what a perceptron computes:
- Multiply each input by its weight: x1*w1, x2*w2, ...
- Add them all up (plus a bias): sum = x1*w1 + x2*w2 + ... + b
- Decide: if sum > 0, output 1. Otherwise, output 0.
That's it. Three steps. Multiply, add, decide.
How does it learn?
The perceptron learning algorithm is beautifully intuitive:
- Start with random weights
- Feed in a training example
- If the prediction is correct β do nothing
- If it predicted 0 but should be 1 β increase the weights (make it more likely to fire next time)
- If it predicted 1 but should be 0 β decrease the weights (make it less likely to fire)
- Repeat for all training examples, multiple times
It's like a teacher nudging a student: "You should have said yes β pay more attention to these features next time."
Perceptron Learning: AND Gate
The XOR problem: the perceptron's fatal flaw
A perceptron can learn AND, OR, and NOT gates perfectly. But it cannot learn XOR (exclusive or: true when inputs differ).
Why? Because XOR isn't linearly separable. You can't draw a single straight line to separate the "on" cases from the "off" cases. Try it β plot (0,0)=0, (0,1)=1, (1,0)=1, (1,1)=0. No single line works.
This limitation was so devastating that it caused the first "AI winter" in the 1970s. The solution? Stack multiple perceptrons into layers β that gives you a neural network, which can solve XOR and much more.