Multi-Layer Perceptron (MLP)
Several layers of neurons with non-linear activations: the classic neural network.
The idea
Adding a hidden layer with a non-linear activation lets the network solve problems a single perceptron cannot, such as XOR. With enough hidden units an MLP can approximate any reasonable function (universal approximation). Weights are trained by backpropagation.
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- predicts 0
- predicts 1
Random weights: the network guesses about 50% everywhere, so the map is a washed-out mush. XOR needs a bent boundary.
- epoch:
- 0
- loss:
- 2.114
- accuracy:
- 50%
Left: what the network predicts across the square. Right: the loss falling. The four ringed dots are XOR's corners.
Step by step
- 1Feed the input through the hidden layer(s).
- 2Apply the activation after each layer.
- 3Compute the output and the loss.
- 4Backpropagate the error.
- 5Update the weights with gradient descent.
Where it is used
Tabular data and as the building block inside larger models.
Watch out for
Needs scaled inputs, a suitable activation and regularisation to avoid overfitting.