Perceptrons: The Humble Beginnings of Artificial Intelligence

Sarah HDD
9 min read1 day ago

--

When we think of artificial intelligence today, we often picture self-driving cars or powerful language models like ChatGPT. But all these advanced systems actually trace their roots back to something much simpler: the perceptron.

It’s like the “hello world” of neural networks — a small yet powerful concept that laid the foundation for the AI we know today.

A Brief History

In the late 1950s, Frank Rosenblatt introduced the perceptron as a mathematical model inspired by how neurons work in the human brain. His work was a major step forward in pattern recognition and machine learning. The perceptron could learn from examples by automatically adjusting its settings — what we call “weights” and “biases” — to improve its accuracy over time. Even if the perceptron started with random settings, it could learn to solve problems like determining whether a specific input belonged to one class or another.

How Does a Perceptron Work?

At its core, a perceptron models a decision as a linear function. Here’s how it works step by step:

  1. Input Layer: The perceptron takes input data in the form of a vector, such as [x1, x2, ..., xn], where each number represents a feature of the data (e.g., pixel intensity in an image).
  2. Weights and Bias: Each input is multiplied by a corresponding weight wi, and a bias b is added to the total.
  3. Summation: All the weighted inputs are summed up to calculate the value: S=w1*x1+w2*x2+...+wn*xn+b
  4. Activation Function: The summation result S passes through an activation function, which determines whether the perceptron’s output will be a 1 (positive class) or 0 (negative class). In this case, the function is simple: If S>0, output=1; otherwise: output=0.

This process is similar to drawing a line in a 2D space to separate points into two categories. The perceptron learns to adjust the line’s position by adjusting its weights and bias.

Learning Algorithm of the Perceptron

The perceptron learns through an iterative process called supervised learning (training on labeled data by adjusting weights based on errors).

Here’s a summary of the steps:

  1. Initialization: Start with random values for weights and bias.
  2. Training Data: Present examples labeled as either 1 or 0.
  3. Prediction: Compute the perceptron’s output for each example.
  4. Update Rule: If the prediction is wrong, update the weights and bias as follows:

wi ​← wi ​+ α * (y − y^​ ) * xi​

  • wi:​ is the weight corresponding to the input feature xi​.
  • α: is the learning rate, which controls how much the weights are adjusted at each step (typically chosen through experimentation: too high can cause instability, too low can slow down convergence).
  • y: is the true label (target value).
  • y^:​ is the predicted label.
  • xi: is the value of the input feature.

This update adjusts the weight wi​ based on the difference between the true label y and the predicted label y^​, scaled by the learning rate and the input feature xi​.

b ← b + α * ( y − y^ ​)

  • b: is the bias term.
  • α: is the learning rate.
  • y: is the true label.
  • y^:​ is the predicted label.

This update adjusts the bias b based on the same error term (y−y^), scaled by the learning rate.

5. Repeat: Continue this process until the perceptron makes no more mistakes or reaches a maximum number of iterations.

Example

We want the perceptron to learn the AND function:

  • Inputs: [x1, x2]
  • Output (y): 1 if both inputs are 1, otherwise 0.

Dataset

                  +-----------+-----------+-----------+
| x1 | x2 | y |
+-----------+-----------+-----------+
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
+-----------+-----------+-----------+

Initialization

  • Weights: w1 = 0, w2 = 0
  • Bias: b = 0
  • Learning rate: α = 0.1

The perceptron uses the following function to predict the output (h(x)):

h(x) = 1 if (w1 * x1 + w2 * x2 + b) > 0, otherwise 0

The weights and bias are updated using:

wi = wi + α * (y - h(x)) * xi
b = b + α * (y - h(x))

Iteration 1 (Epoch 1)

  1. Input: [0, 0], y = 0
    h(x) = 0
    No update since y = h(x).
  2. Input: [0, 1], y = 0
    h(x) = 0
    No update since y = h(x).
  3. Input: [1, 0], y = 0
    h(x) = 0
    No update since y = h(x).
  4. Input: [1, 1], y = 1
    h(x) = 0 (since 0 * 1 + 0 * 1 + 0 = 0 <= 0)
    Update weights and bias:
w1 = 0 + 0.1 * (1 - 0) * 1 = 0.1
w2 = 0 + 0.1 * (1 - 0) * 1 = 0.1
b = 0 + 0.1 * (1 - 0) = 0.1

Iteration 2 (Epoch 2)

  1. Input: [0, 0], y = 0
    h(x) = 1 (since 0.1 * 0 + 0.1 * 0 + 0.1 = 0.1 > 0)
    Update weights and bias:
w1 = 0.1 + 0.1 * (0 - 1) * 0 = 0.1
w2 = 0.1 + 0.1 * (0 - 1) * 0 = 0.1
b = 0.1 + 0.1 * (0 - 1) = 0

2. Input: [0, 1], y = 0
h(x) = 1 (since 0.1 * 0 + 0.1 * 1 + 0 = 0.1 > 0)
Update weights and bias:

w1 = 0.1 + 0.1 * (0 - 1) * 0 = 0.1
w2 = 0.1 + 0.1 * (0 - 1) * 1 = 0
b = 0 + 0.1 * (0 - 1) = -0.1

3. Input: [1, 0], y = 0
h(x) = 0
No update since y = h(x).

4. Input: [1, 1], y = 1
h(x) = 0(since 0.1 * 1 + 0 * 1 — 0.1 = 0 <= 0)
Update weights and bias:

w1 = 0.1 + 0.1 * (1 - 0) * 1 = 0.2
w2 = 0 + 0.1 * (1 - 0) * 1 = 0.1
b = -0.1 + 0.1 * (1 - 0) = 0

Iteration 3 (Epoch 3)

  1. Input: [0, 0], y = 0
    h(x) = 0
    No update since y = h(x).

2. Input: [0, 1], y = 0
h(x) = 1 (since 0.2 * 0 + 0.1 * 1 + 0 = 0.1 > 0)
Update weights and bias:

w1 = 0.2 + 0.1 * (0 - 1) * 0 = 0.2
w2 = 0.1 + 0.1 * (0 - 1) * 1 = 0
b = 0 + 0.1 * (0 - 1) = -0.1

3. Input: [1, 0], y = 0
h(x) = 1 (since 0.2 * 1 + 0 * 0 — 0.1 = 0.1 > 0)
Update weights and bias:

w1 = 0.2 + 0.1 * (0 - 1) * 1 = 0.1
w2 = 0 + 0.1 * (0 - 1) * 0 = 0
b = -0.1 + 0.1 * (0 - 1) = -0.2

4. Input: [1, 1], y = 1
h(x) = 0(since 0.1 * 1 + 0 * 1 — 0.2 = -0.1 <= 0)
Update weights and bias:

w1 = 0.1 + 0.1 * (1 - 0) * 1 = 0.2
w2 = 0 + 0.1 * (1 - 0) * 1 = 0.1
b = -0.2 + 0.1 * (1 - 0) = -0.1

Iteration 4 (Epoch 4)

  1. Input: [0, 0], y = 0
    h(x) = 0
    No update since y = h(x).

2. Input: [0, 1], y = 0
h(x) = 0
No update since y = h(x).

3. Input: [1, 0], y = 0
h(x) = 1 (since 0.2 * 1 + 0.1 * 0 — 0.1 = 0.1 > 0)
Update weights and bias:

w1 = 0.2 + 0.1 * (0 - 1) * 1 = 0.1
w2 = 0.1 + 0.1 * (0 - 1) * 0 = 0.1
b = -0.1 + 0.1 * (0 - 1) = -0.2

4. Input: [1, 1], y = 1
h(x) = 0(since 0.1 * 1 + 0.1 * 1 — 0.2 = 0 <= 0)
Update weights and bias:

w1 = 0.1 + 0.1 * (1 - 0) * 1 = 0.2
w2 = 0.1 + 0.1 * (1 - 0) * 1 = 0.2
b = -0.2 + 0.1 * (1 - 0) = -0.1

Iteration 5 (Epoch 5)

  1. Input: [0, 0], y = 0
    h(x) = 0
    No update since y = h(x).

2. Input: [0, 1], y = 0
h(x) = 1 (since 0.2 * 0 + 0.2 * 1 — 0.1 = 0.1 > 0)
Update weights and bias:

w1 = 0.2 + 0.1 * (0 - 1) * 0 = 0.2
w2 = 0.2 + 0.1 * (0 - 1) * 1 = 0.1
b = -0.1 + 0.1 * (0 - 1) = -0.2

3. Input: [1, 0], y = 0
h(x) = 0
No update since y = h(x).

4. Input: [1, 1], y = 1
h(x) = 1
No update since y = h(x).

After 5 epochs, the perceptron has successfully learned the AND function! Let’s verify the final weights and bias:

  • w1 = 0.2
  • w2 = 0.1
  • b = -0.2

Let’s verify all cases with these final values:

  1. [0, 0]: 0.2 * 0 + 0.1 * 0 + (-0.2) = -0.2 ≤ 0 → output 0 ✓
  2. [0, 1]: 0.2 * 0 + 0.1 * 1 + (-0.2) = -0.1 ≤ 0 → output 0 ✓
  3. [1, 0]: 0.2 * 1 + 0.1 * 0 + (-0.2) = 0 ≤ 0 → output 0 ✓
  4. [1, 1]: 0.2 * 1 + 0.1 * 1 + (-0.2) = 0.1 > 0 → output 1 ✓

The perceptron has successfully learned to classify all inputs correctly according to the AND function!

Successes and Shortcomings

The perceptron works when data is linearly separable — meaning a straight line (or hyperplane in higher dimensions) can divide the data into two categories. Like in the previous example, we have seen that it can model logical functions like AND. It also works perfectly with the logical function OR, since both AND and OR functions are linearly separable.

However, it fails for problems like XOR, where no straight line can separate the classes. This limitation was highlighted by Marvin Minsky and Seymour Papert in 1969, stalling progress in AI research for years. But the perceptron’s core principles were later extended to create multilayer networks, overcoming these challenges and paving the way for deep learning.

To visualize why the AND function works with a perceptron:

  • For AND, we can draw a line that perfectly separates the positive case (1,1) from the negative cases (0,0), (0,1), and (1,0)
  • Our trained weights and bias (w1=0.2, w2=0.1, b=-0.2) define exactly such a line
  • The equation w1 * x1 + w2 * x2 + b = 0 represents this decision boundary
The AND function with the perceptron decision boundary

This geometric interpretation helps explain why the perceptron could successfully learn the AND function but would fail on XOR, where no single straight line can separate the positive cases (0,1 and 1,0) from the negative cases (0,0 and 1,1).

The XOR function with the perceptron decision boundaries

Why Does It Matter?

The perceptron’s elegance lies in its simplicity. It introduced key concepts — weights, biases, activation functions (functions that decide the output of a neuron, such as sigmoid or ReLU, and help capture non-linear patterns), and learning — that are fundamental to modern AI. While it’s no longer used in its original form, understanding it is crucial for comprehending how neural networks operate.

A Legacy of Growth

From a simple algorithm that could only draw a line, AI has grown into a field capable of solving problems across vision, language, and robotics. The perceptron reminds us that even the most complex systems start with basic ideas — a lesson not just for AI enthusiasts but for anyone addressing challenges in life.

So, the next time you admire a cutting-edge AI system, take a moment to appreciate its humble beginnings. Because just like the perceptron, great achievements often start with a simple yet powerful idea.

--

--

Sarah HDD
Sarah HDD

Written by Sarah HDD

Hi! I’m Sarah, an AI Engineer specializing in Computer Vision. Since I’m passionate about Computer Vision, I enjoy writing about it in a friendly manner.

No responses yet