Multi-Layer Perceptrons
A Multi-Layer Perceptron (MLP) is a class of artificial neural network composed of an input layer, one or more hidden layers, and an output layer — where every neuron in one layer connects to every neuron in the next. MLPs are the backbone of modern deep learning, serving as the foundational building block that more sophisticated architectures like transformers and convolutional nets are built upon or extend. Remarkably, a single hidden-layer MLP with enough neurons can theoretically approximate any continuous function — a property known as the Universal Approximation Theorem.
An MLP learns by adjusting the strength (weight) of connections between neurons so that a given input reliably produces a desired output. Each layer transforms the data into a new representation, progressively extracting more abstract features — the first layer might detect simple patterns, the next layer combines those into shapes, and so on. The "learning" part is just the network repeatedly making predictions, measuring how wrong it was, and nudging every weight slightly in the direction that reduces that error. If you understand this loop — forward pass, measure error, backward pass, update weights — you understand the heart of modern deep learning.
How It Works
An MLP passes data through a series of transformations. At each layer, every neuron computes a weighted sum of its inputs, adds a bias term, then passes the result through a nonlinear activation function.
Explanation: Each neuron computes a weighted sum of its inputs plus a bias — this is just a linear combination before the nonlinearity is applied.
- x₁ … xₙ — the input values arriving from the previous layer
- w₁ … wₙ — learned weights, one per input connection
- b — the bias, a learned offset that shifts the output independently of the inputs
- z — the pre-activation output, sometimes called the "logit"
The weighted sum alone is linear, meaning stacking many such layers would still only produce a linear function of the input. Activation functions break this limitation:
Explanation: Applying a nonlinear activation function to z allows the network to model curved, complex relationships rather than just straight lines and planes.
- σ — the activation function (e.g., ReLU, sigmoid, or tanh)
- a — the activated output, which becomes the input to the next layer
The most popular modern activation function is ReLU (Rectified Linear Unit):
Explanation: ReLU simply outputs zero for any negative input and passes positive inputs through unchanged — a surprisingly effective nonlinearity that trains quickly and avoids saturation. Training minimizes a loss function that measures prediction error. For a regression task the common choice is Mean Squared Error:
Explanation: The loss averages the squared difference between each true label and the network's prediction — larger errors are penalized more heavily because of the squaring.
- N — number of training examples in the batch
- yᵢ — the true label for example i
- ŷᵢ — the network's predicted value for example i
Here is a minimal working MLP in Python using PyTorch, showing the full structure: ```python import torch import torch.nn as nn
# Define a simple MLP: 2 inputs → 4 hidden → 1 output class SimpleMLP(nn.Module): def __init__(self): super().__init__() self.layers = nn.Sequential( nn.Linear(2, 4), # input layer → hidden layer (4 neurons) nn.ReLU(), # activation function nn.Linear(4, 1) # hidden layer → output ) def forward(self, x): return self.layers(x) model = SimpleMLP()
# Dummy training step optimizer = torch.optim.SGD(model.parameters(), lr=0.01) loss_fn = nn.MSELoss() x = torch.tensor(1.0, 2.0) # one input sample y = torch.tensor(3.0) # target pred = model(x) # forward pass loss = loss_fn(pred, y) # compute loss loss.backward() # backpropagation optimizer.step() # update weights print(f"Loss: {loss.item():.4f}") ``` ``` Loss: 7.2341 # (will vary — weights are random initially) ```
Hinton is a British-Canadian cognitive psychologist and computer scientist who spent most of his career at the University of Toronto before joining Google. His 1986 paper with Rumelhart and Williams popularized backpropagation as a practical training algorithm for MLPs, directly enabling the modern deep learning era. Remarkably, Hinton resigned from Google in 2023 citing concerns about AI safety — and shared the 2024 Nobel Prize in Physics for his foundational work on artificial neural networks.
Intuition
Think of an MLP like a factory assembly line where raw materials (your input data) pass through a series of workstations (layers). At each workstation, workers (neurons) examine what they receive, decide which aspects are interesting (via weights), and pass a transformed version forward. The first workstation might notice basic features — "this input is large" or "these two inputs are similar." The second workstation combines those observations into higher-level conclusions — "this pattern looks like category A." By the time the product reaches the end of the line (the output layer), it has been transformed from raw data into a useful prediction or classification. Training is like a manager walking the line backward after each bad product comes out, telling each workstation "do slightly more of this, slightly less of that" — this is backpropagation. Another way to feel it: imagine tuning a radio. Each weight is a dial. Right now the dials are all random and you hear static (random predictions). You listen, measure how far you are from your favorite station, nudge the dials a tiny bit in the right direction, and repeat thousands of times. Eventually the static resolves into a clear signal. The network hasn't been told the rules — it discovered them by iterating.
Historical Development
Origins · 1 minhow this was discovered
Why It Matters
Prerequisites
What This Leads To
See Also
Backpropagation · Activation Functions · Gradient Descent Optimization · Universal Approximation Theorem · Convolutional Neural Networks · Dropout Regularization · Batch Normalization