AI State of the Art
Fundamentals/Machine Learning: The Basics/22 min
Section 7

The Perceptron and Simple Neural Networks

Listen as a podcast β†’

Introduction: The Foundation of Everything

Your brain contains 86 billion neurons. Each one receives signals, accumulates them, and if it exceeds a threshold, sends a signal. It's mechanical. Electrical. Simple.

The perceptron is the mathematical imitation of this. Frank Rosenblatt invented it in 1957. It's tiny. Trivial. But it's the fundamental building block of all modern deep learning. The Transformers that power GPT-4? Millions of stacked perceptrons.

Understanding the perceptron = understanding the foundation.

The Biological Neuron: The Inspiration

Real neurons:

  1. Receive signals via dendrites (inputs)
  2. Accumulate in the cell body
  3. If the signal exceeds a threshold, the neuron fires
  4. Send a signal along the axon (output) via synapses
Diagram of a biological neuron with annotations
This image illustrates how a biological neuron works, compared to an artificial perceptron. The dendrites receive the input signals (X1, X2, ..., Xn), which are processed in the cell body (soma) before being transmitted via the axon (output Y1, Y2, ..., Ym) if an activation threshold is exceeded.Source : Wikipedia

The artificial perceptron simulates this mathematically.

The Simple Perceptron: The Mechanism

Diagram of how a simple perceptron works
This diagram illustrates the fundamental mechanism of a simple perceptron: the linear combination of weighted inputs followed by a step activation function. It shows how inputs (x1, x2) are multiplied by their respective weights (w1, w2), added with a bias (b), then passed through an activation function to produce a binary output.Source : Muneeb S. A., Medium

Takes numbers as input (x1,x2,…,xnx_1, x_2, \ldots, x_n). Outputs a number between 0 and 1.

Step 1: The Linear Combination

z=w1β‹…x1+w2β‹…x2+…+wnβ‹…xn+bz = w_1 \cdot x_1 + w_2 \cdot x_2 + \ldots + w_n \cdot x_n + b

Symbol by symbol:

  • x1,…,xnx_1, \ldots, x_n: the inputs. They change with every example presented.
  • w1,…,wnw_1, \ldots, w_n: the weights. Each weight says how much the matching input counts. These are learned parameters: training searches for them, and once training ends they stop moving.
  • bb: the bias, also a learned parameter. A constant offset added whatever the inputs are: it shifts the threshold at which the neuron fires.
  • zz: the result of the computation. Not a parameter, a value recomputed for every example.

In one sentence: each input is multiplied by its importance, everything is added up, an offset is added, and the bigger the total the more excited the neuron. Hold on to the split: ww and bb are learned and frozen; xx and zz are recomputed on every pass.

Step 2: The Activation Function (Step Function)

Transforms zz into the final output.

For the simple perceptron, the activation function is the step function:

  • If zβ‰₯0z \geq 0, output = 1
  • If z<0z < 0, output = 0

It's binary. All or nothing. The neuron "fires" or doesn't.

Concrete Example

Inputs: x1=0.5x_1 = 0.5, x2=2.0x_2 = 2.0

Weights: w1=1w_1 = 1, w2=1w_2 = 1, Bias: b=βˆ’1.5b = -1.5

z=1Γ—0.5+1Γ—2βˆ’1.5=1.0z = 1 \times 0.5 + 1 \times 2 - 1.5 = 1.0

Since 1.0β‰₯01.0 \geq 0, output = 1

Geometric Interpretation: Separating the Space

Mathematically, the perceptron defines a line (in 2D) or a plane (in 3D) or a hyperplane (in higher dimensions) that divides the space.

Points on one side are classified 0, on the other side 1.

Visual 2D example (with w1=1,w2=1,b=βˆ’1.5w_1 = 1, w_2 = 1, b = -1.5):

InputszzOutput
(0,0)(0, 0)βˆ’1.5-1.50
(0,1)(0, 1)βˆ’0.5-0.50
(1,0)(1, 0)βˆ’0.5-0.50
(1,1)(1, 1)0.50.51

This is the AND logic gate: the output is 1 only when both inputs are 1.

The Simple Perceptron's Dilemma

The perceptron can only draw lines (or planes). If the data isn't linearly separable, the algorithm never converges.

Problematic example: XOR.

InputsXOR Output
(0,0)(0, 0)0
(0,1)(0, 1)1
(1,0)(1, 0)1
(1,1)(1, 1)0

There is no straight line putting both 1s on one side and both 0s on the other. Sketch it: the 1s sit at (0,1)(0,1) and (1,0)(1,0), so on one diagonal of the square; the 0s sit at (0,0)(0,0) and (1,1)(1,1), on the other. The two diagonals cross, so any line you draw is forced to leave a 1 and a 0 on the same side.

In 1969, Minsky and Papert prove that the simple perceptron can never solve XOR. This is not a programming mistake someone could patch: it is a mathematical impossibility. The effect on the field is brutal, funding dries up, and the "first AI winter" begins.

Diagram of AND, OR, and XOR logic gates
The image illustrates the limitations of the simple perceptron: it can solve the AND and OR logic gates, but not XOR. This mathematically demonstrates why the simple perceptron cannot solve all linear classification problems.Source : PyImageSearch

The Multi-Layer Perceptron: The Solution

How to solve XOR? Add a hidden layer between the input and the output.

Architecture

Input (2 neurons)⟢Hidden layer (2 neurons)⟢Output (1 neuron)\text{Input (2 neurons)} \longrightarrow \text{Hidden layer (2 neurons)} \longrightarrow \text{Output (1 neuron)}

Each neuron in a layer connects to all neurons in the next. This is a Multi-Layer Perceptron (MLP).

Diagram of a Multi-Layer Perceptron (MLP)
This diagram illustrates the architecture of a Multi-Layer Perceptron (MLP), where each neuron in a layer is fully connected to all neurons in the next layer. This enables information to propagate through hidden layers to produce an output.Source : ResearchGate

Why It Works for XOR

Hidden layer: 2 neurons.

  • Neuron 1: learns "x1x_1 OR x2x_2" (at least one 1)
  • Neuron 2: learns "NOT (x1x_1 AND x2x_2)" (not both 1)

Output layer: combines both.

  • "Neuron 1 AND Neuron 2" = XOR!

The hidden layer transforms the space. It makes the problem linearly separable.

Fundamental Intuition

Each hidden layer warps the data space. It's as if the network flattens the data to make it "cuttable" by a straight line. More layers = more possible deformations = more complex patterns capturable.

Visualization of non-linearly separable XOR data
This image illustrates a classic non-linearly separable problem (XOR) where the data forms four distinct clusters. It shows why a simple perceptron (single layer) cannot solve this problem without transforming the data.Source : ResearchGate

Activation Functions

Without an activation function (or with a linear one), stacking 100 linear layers equals a single linear layer.

LayerΒ 1:Β y=W1β‹…x+b1\text{Layer 1: } y = W_1 \cdot x + b_1 LayerΒ 2:Β z=W2β‹…y+b2=W2β‹…(W1β‹…x+b1)+b2=Wβ€²β‹…x+bβ€²\text{Layer 2: } z = W_2 \cdot y + b_2 = W_2 \cdot (W_1 \cdot x + b_1) + b_2 = W' \cdot x + b'

W1W_1 and W2W_2 are the two layers' weight tables, b1b_1 and b2b_2 their biases, all learned. The final equality says that once expanded, you are left with a single multiplication by a table Wβ€²=W2β‹…W1W' = W_2 \cdot W_1 and a single shift bβ€²=W2β‹…b1+b2b' = W_2 \cdot b_1 + b_2. In other words: two purely linear stacked layers are exactly equivalent to one, and nothing was gained by using two.

It is non-linearity that gives the network its power. Which non-linearity to choose (step, sigmoid, hyperbolic tangent, ReLU and its descendants) is the subject of its own lesson: Activation Functions.

Backpropagation: How Learning Happens

How does an MLP learn? Through backpropagation, discovered by Rumelhart, Hinton, and Williams in 1986.

The reference

Rumelhart, Hinton and Williams, Learning representations by back-propagating errors, Nature 323, pp. 533-536, 1986. The paper predates arXiv, so there is no preprint link to give.

Error computation diagram in a perceptron
This diagram illustrates the backpropagation process in a simple neural network. The error between the predicted output and the actual output is computed, then propagated backward to adjust the network weights.Source : Medium

Process:

  1. Forward pass: data passes through the network, produces a prediction.

  2. Loss computation: compare prediction vs reality. Measure the error (MSE, cross-entropy, etc.)

  3. Backward pass: compute how each weight contributes to the error. Uses the chain rule to propagate the gradient layer by layer, from output to input.

  4. Weight update: each weight moves in the direction that reduces the error.

w=wβˆ’Ξ±β‹…βˆ‚Lβˆ‚ww = w - \alpha \cdot \frac{\partial \mathcal{L}}{\partial w}

Symbol by symbol: ww is the weight being corrected; L\mathcal{L} (script "L") is the loss, the number measuring the error; βˆ‚Lβˆ‚w\frac{\partial \mathcal{L}}{\partial w} is the weight's gradient, meaning "how much the loss rises if I raise ww a hair"; and Ξ±\alpha ("alpha") is the learning rate, the fraction of that advice you agree to follow, the step size.

The minus sign is the whole point: if raising the weight raises the error, lower the weight. You always move against the direction the gradient marks as uphill.

Illustration of gradient descent
This image shows how the learnable parameter (w) is iteratively adjusted by following the opposite direction of the loss function gradient (dL/dw), with a learning rate alpha that determines the step size.Source : ResearchGate

SGD: Mini-batches and Randomness

You do not update the weights only after sweeping all the data, far too slow. You work in mini-batches of 32, 64 or 128 examples at a time.

Stochastic Gradient Descent (SGD): "stochastic" just means "at random", because the batches are drawn at random from the data. The result is a bit noisy, and that noise sometimes helps escape a bad hollow.

Modern optimizers such as Adam, RMSprop or AdaGrad adapt the learning rate weight by weight instead of imposing a single one on the whole network. They usually converge faster than plain SGD; that is the subject of Modern optimizers.

Comparison of gradient descent variants
The image illustrates three variants of gradient descent: Batch (all examples), Mini-Batch (subsets), and Stochastic (one example at a time), showing their impact on convergence toward the global minimum.Source : DEV Community

The Universal Approximation Theorem

George Cybenko, 1989:

Universal Approximation Theorem

An MLP with JUST ONE hidden layer containing enough neurons can approximate any continuous function, to any desired precision.

The reference

G. Cybenko, Approximation by Superpositions of a Sigmoidal Function, Mathematics of Control, Signals and Systems 2, pp. 303-314, 1989. Again a pre-arXiv paper: no preprint link.

In other words: a multi-layer perceptron can in principle learn any regularity.

But it's misleading.

Yes, theoretically it's true. In practice? The number of neurons needed can be astronomical. To capture a simple pattern, you might need billions of neurons.

This is where deep learning comes in: use many layers, each relatively thin. Much more efficient than a single giant layer.

From the Perceptron to Deep Learning

Historical path:

YearBreakthroughAuthors
1957PerceptronRosenblatt
1969AI Winter (XOR impossible)Minsky & Papert
1986Backpropagation -> powerful MLPRumelhart, Hinton, Williams
1997LSTM for sequencesHochreiter, Schmidhuber
1998Convolutional networks (CNN) for imagesLeCun
2017TransformersVaswani et al.
2022-2024Giant LLMs (ChatGPT, Claude, Llama),

Each step = architectural innovation. But the fundamental principle: neurons with weights, non-linearities, gradient-based learning, backpropagation. It's still the perceptron, just more sophisticated.

The Real Secret of Deep Learning

The success of modern deep learning doesn't come just from deep architectures. It also comes from:

  • Smart weight initialization (Xavier, He)
  • Normalization (BatchNorm, LayerNorm)
  • Regularization (dropout, weight decay)
  • Adaptive optimization (Adam)
  • Data augmentation (manufacturing variants of the examples you already have)

Each solves a practical problem in training deep networks.

Why This Matters

The perceptron is the conceptual and historical foundation of all deep learning. By understanding its mechanisms (weights, biases, activation, backpropagation), you have the keys to understanding GPT-4, CNNs for vision, Transformers for language. Everything builds on it.

Check your understanding0 / 5

1. In the perceptron computation z = w_1 Β· x_1 + … + b, which pieces are learned during training and then frozen?

2. Why can a simple perceptron never learn XOR?

3. What do you get by stacking two purely linear layers, with no activation function between them?

4. The universal approximation theorem says one hidden layer is enough to approximate any continuous function. Why do we build deep networks anyway?

5. In the update rule w = w βˆ’ Ξ± Β· gradient, what does the minus sign guarantee?