Multi-layer Perceptron (MLP)

Machine Learning
Introduced by
Rumelhart, D. E., Hinton, G. E., & Williams, R. J.
Year
1986
Type
Feedforward neural network (supervised learning)

What does it do?

The Multi-layer Perceptron (MLP) is a feedforward neural network trained by backpropagation, a method popularised for multilayer networks by Rumelhart, Hinton, and Williams in their 1986 Nature paper.

It consists of an input layer, one or more hidden layers of neurons with nonlinear activation functions, and an output layer. Under mild conditions on the activation function, a network with a hidden layer can approximate any continuous function on a compact domain to arbitrary accuracy given enough hidden neurons, which makes the MLP a conceptual bridge between classical machine learning and modern deep learning.

The intuition behind the method

Think of an MLP as a chain of filters. Raw input features pass through the first filter (hidden layer), which learns to detect simple patterns; the output of that filter feeds the next, which combines those patterns into higher-level abstractions; and so on until the final layer produces a prediction. What makes training possible is backpropagation: after the network makes a prediction, the error is sent backwards through the chain, and each weight is nudged slightly in the direction that reduces that error. Repeat this over many examples and the network learns which patterns matter.

History

The perceptron, introduced by Frank Rosenblatt in 1958, showed that a single layer of weighted connections could learn linear classifications. Minsky and Papert's 1969 analysis showed that single-layer perceptrons cannot solve non-linearly separable problems such as XOR, and neural network research lost much of its momentum afterwards. The 1986 Nature paper by Rumelhart, Hinton, and Williams, 'Learning representations by back-propagating errors' (volume 323, pp. 533–536), showed that gradient-based credit assignment through multiple hidden layers could learn useful internal representations, and it popularised backpropagation as a training method for such networks. Work through the 1990s by LeCun, Hochreiter, Schmidhuber, and others extended the architecture to convolutional and recurrent networks, and from 2012 AlexNet's ImageNet result helped establish deep networks trained on GPUs with large datasets as the standard approach.

When to use it

Choose an MLP when the relationship between inputs and outputs is nonlinear with complex feature interactions, the data are vectorised (tabular records, extracted features, or embeddings), and predictive accuracy matters more than inspecting individual coefficients. No reliable minimum training-set size exists for an MLP. The data required grow with the number of trainable parameters, which increases with depth and width, so a small network can be trained on modest data while a wide or deep one needs far more to avoid overfitting. Use a validation set or cross-validation to judge whether the available data are sufficient for the architecture under consideration. MLPs handle binary, multi-class, and regression tasks on such inputs. Do not use an MLP as a first choice for raw images (convolutional networks are built for spatial structure), for sequential data where order matters (recurrent networks or Transformers), or for small datasets where logistic regression or a regularised linear model is likely to generalise better. The method assumes training examples are independent and identically distributed, and temporal dependence between rows violates this. Depth, width, activation, learning rate, and regularisation strongly affect results and must be tuned on validation data.

Limitations and considerations

  • Requires substantial labelled data: with small datasets the model overfits easily and simpler models such as logistic regression or random forests typically generalise better.
  • Computationally intensive: training large networks demands significant time and (for very deep models) GPU resources.
  • Black-box predictions: individual weights are not interpretable. Post-hoc explanation methods such as SHAP or LIME can be applied to approximate feature contributions, but they describe the model's behaviour and do not reveal the meaning of its weights.
  • Sensitive to hyperparameters: depth, width, activation function, learning rate, and regularisation strength all interact, and poor choices can prevent convergence or cause severe overfitting.
  • Prone to vanishing and exploding gradients in very deep networks, though modern activations (ReLU), initialisation schemes, and batch normalisation largely mitigate this.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Universal approximation: under mild conditions on the activation function, a network with at least one hidden layer can approximate any continuous function on a compact domain to arbitrary accuracy, provided it has enough hidden neurons. The result is existential: it does not say how many neurons are needed or how training will find suitable weights.
  • Flexible output: the same architecture supports binary classification (sigmoid output with binary cross-entropy), multi-class classification (softmax output with categorical cross-entropy), and regression (linear output with mean squared error), with the change confined to the output layer.
  • Composable: the MLP is the feedforward building block of many deep architectures, including the dense layers of convolutional networks and the feedforward sublayers of Transformers, so the same training ideas carry over.
  • Established regularisation options: dropout, weight decay (L2), and early stopping are standard ways to limit overfitting, and batch normalisation is commonly used to stabilise training of deeper MLPs.

Applications

  • Tabular classification and regression where feature interactions are nonlinear and a linear model underfits.
  • Multi-output prediction, where several related targets are predicted jointly by one network.
  • Feature learning: using the hidden-layer activations of a trained MLP as input representations for a downstream model.
  • Risk modelling such as credit scoring or medical diagnosis, where a large labelled dataset is available.
  • Fully connected blocks inside larger architectures, including the dense layers of convolutional networks and the feedforward sublayers of Transformers.

How it works

How it works

1

Each neuron in layer l computes a weighted sum of the activations from the previous layer, adds a bias, and passes the result through a nonlinear activation function (such as ReLU, tanh, or sigmoid). Writing z^(l) = W^(l) a^(l-1) + b^(l) for the pre-activation, the layer output is a^(l) = σ(z^(l)), which is the notation used in the backpropagation step. This forward pass transforms the input vector through successive hidden representations until the output layer produces a prediction. Without nonlinear activation functions the entire stack would collapse to a single linear transformation.

Formula
\mathbf{a}^{(l)} = \sigma\!\left(\mathbf{W}^{(l)}\mathbf{a}^{(l-1)} + \mathbf{b}^{(l)}\right)
2

A loss function quantifies how wrong the network's predictions are: cross-entropy is standard for classification, mean squared error for regression. The scalar loss value is the signal that drives learning — the goal of training is to minimise it over the training set.

Formula
\mathcal{L} = \frac{1}{n}\sum_{i=1}^{n} \ell\!\left(\hat{y}_i,\, y_i\right)
3

Backpropagation applies the chain rule of calculus to propagate the gradient of the loss backwards through the network layer by layer. For each hidden layer l, the error signal (delta, defined as the derivative of the loss with respect to z^(l)) is computed by weighting the deltas from the layer above by the transpose of that layer's weight matrix and multiplying element-wise by the derivative of the activation function. The recursion starts at the output layer, where delta is the derivative of the loss with respect to the output pre-activation. This efficiently attributes credit or blame to every weight in the network.

Formula
\boldsymbol{\delta}^{(l)} = \left(\mathbf{W}^{(l+1)\top}\boldsymbol{\delta}^{(l+1)}\right) \odot \sigma'\!\left(\mathbf{z}^{(l)}\right)
4

Once all gradients are computed, each weight is shifted by a small step in the direction that decreases the loss, scaled by the learning rate eta. In practice this update is performed with minibatch stochastic gradient descent (SGD) or an adaptive variant such as Adam or RMSprop. The cycle of forward pass, loss computation, backpropagation, and weight update is repeated for many epochs until the loss converges.

Formula
\mathbf{W}^{(l)} \leftarrow \mathbf{W}^{(l)} - \eta\,\frac{\partial \mathcal{L}}{\partial \mathbf{W}^{(l)}}

Common pitfalls

  • Skipping feature normalisation: MLPs are sensitive to the scale of inputs; always standardise or normalise input features before training.
  • Training without a held-out validation set or cross-validation, leading to over-optimistic performance estimates.
  • Choosing network depth and width by trial and error without any principled search; use a systematic hyperparameter search (grid, random, or Bayesian).
  • Ignoring class imbalance when using cross-entropy loss; re-weight classes or oversample the minority class.
  • Stopping training at a fixed number of epochs rather than monitoring validation loss and using early stopping to avoid overfitting.

Frequently asked questions

How many hidden layers and neurons should I use?

There is no universal answer. A single hidden layer with enough neurons can approximate continuous functions in principle, but that result does not say how many neurons are needed. Deeper networks can represent some functions more compactly, but whether they generalise better on a given problem must be checked on validation data. Start with a small architecture, increase capacity only if the model underfits, and add regularisation if it overfits.

Which activation function should I choose?

ReLU (rectified linear unit) is the usual default for hidden layers in modern MLPs: it is computationally cheap, mitigates the vanishing gradient problem at moderate depths, and works well in practice. Sigmoid and tanh are still used in specific contexts, for example a sigmoid output for binary classification or gated architectures. Leaky ReLU, ELU, and GELU are reasonable alternatives when neurons die with standard ReLU.

How do I know if my MLP is overfitting?

Monitor training loss and validation loss simultaneously. If validation loss stops decreasing while training loss keeps falling, the model is overfitting. Use early stopping to halt training at the point of best validation performance. Dropout and weight decay (L2 regularisation) are standard remedies.

When should I prefer an MLP over simpler models like logistic regression or random forest?

Prefer an MLP when the input-output relationship is strongly nonlinear, feature interactions are complex, and you have enough data for the network to learn those patterns reliably. With small datasets or when interpretability is essential, logistic regression or a regularised linear model is often safer. On tabular data, tree ensembles such as random forests are often a strong baseline that needs less tuning, so they are worth comparing against an MLP.

Related methods

Sources

  1. Rumelhart, D. E., Hinton, G. E., & Williams, R. J. (1986). Learning representations by back-propagating errors. Nature, 323, 533–536.

    Open DOI reference
  2. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning (Ch. 6–7). MIT Press.

    ISBN: 978-0-262-03561-3
  3. Bishop, C. M. (2006). Pattern Recognition and Machine Learning (Ch. 5). Springer.

    ISBN: 978-0-387-31073-2