Skip to content
StackDecode
AI & ML Atlas
Neural NetworksarchitectureInteractive simulation

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.

loss over epochs
  • 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%
1/15

Left: what the network predicts across the square. Right: the loss falling. The four ringed dots are XOR's corners.

Step by step

  1. 1Feed the input through the hidden layer(s).
  2. 2Apply the activation after each layer.
  3. 3Compute the output and the loss.
  4. 4Backpropagate the error.
  5. 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.

Related