Multilayer perceptron

Multilayer perceptrons, or MLPs, are the foundational "vanilla" neural networks that powered the early successes of modern deep learning. Unlike their simpler predecessors, MLPs possess a remarkable ability to understand and classify data that isn't neatly separable by a straight line. Join us as we explore how these layered structures learn to unravel complex patterns in the world. Multilayer perceptrons overcome the limitations of single-layer models by using multiple layers and non-linear activation functions, allowing them to learn complex, non-linear relationships in data. Their architecture consists of interconnected layers—an input, one or more hidden layers, and an output—where each connection carries a tunable weight. MLPs learn through a powerful process called backpropagation, which efficiently adjusts these connection weights by calculating and propagating error signals backward through the network.

Source: Wikipedia

AI Summary

Multilayer perceptrons, or MLPs, are the foundational "vanilla" neural networks that powered the early successes of modern deep learning. Unlike their simpler predecessors, MLPs possess a remarkable ability to understand and classify data that isn't neatly separable by a straight line. Join us as we explore how these layered structures learn to unravel complex patterns in the world.

The Multilayer Perceptron: A Deep Dive

At its heart, a Multilayer Perceptron (MLP) is a modern type of artificial neural network. It's considered a 'feedforward' network, meaning information flows in one direction, from input to output, without looping back. Think of it as a series of computational steps that transform raw data into a meaningful prediction or classification.

What makes an MLP so special is its ability to learn and distinguish data that isn't linearly separable. This was a significant leap beyond earlier models like the single-layer perceptron, which could only handle patterns that could be divided by a straight line or plane. MLPs unlock the door to much more complex problem-solving.

Anatomy of an MLP: Layers of Intelligence

An MLP's power comes from its layered structure. It typically consists of at least three layers: an input layer, one or more 'hidden' layers, and an output layer. Each layer is made up of numerous 'neurons' or 'nodes'—simple processing units—that are fully connected to every node in the subsequent layer.

These connections between neurons aren't just pathways; they carry 'weights.' Each weight is a numerical value that determines the strength and influence of a connection. It's these weights that the network adjusts during learning, effectively encoding the knowledge it gains from the data.

The Magic of Non-Linearity: Activation Functions

A crucial ingredient in an MLP's ability to learn complex patterns is the 'activation function.' If all neurons in an MLP used only linear activation functions—a simple weighted sum—then no matter how many layers you added, the entire network would behave like a single-layer model. It would still only be able to solve linearly separable problems.

Non-linear activation functions introduce complexity, allowing the network to model intricate relationships in the data. They essentially decide whether a neuron 'fires' and how strongly. This concept is inspired by biological neurons, which either fire an action potential or don't, and at varying frequencies.

Historically, common choices included the logistic function, also known as the sigmoid, and the hyperbolic tangent (tanh). The sigmoid compresses any input into an output between 0 and 1, useful for probabilities. The tanh function is similar, but its output ranges from -1 to 1, often centering data better for training.

In more recent deep learning, a simpler function called the Rectified Linear Unit, or ReLU, has become incredibly popular. It outputs the input directly if it's positive, and zero otherwise. ReLU helps overcome certain numerical problems, like the 'vanishing gradient' problem, that plagued older activation functions, allowing deeper networks to train more effectively.

Learning from Mistakes: Backpropagation

How does an MLP learn these intricate patterns? Through a process called 'backpropagation,' a generalization of the classic least mean squares algorithm. This is a form of 'supervised learning,' meaning the network is trained on data where the correct answers are already known, allowing it to compare its predictions against reality.

During training, an input is fed through the network, producing an output. This output is then compared to the desired target value, and the 'error' is calculated. For any given output node 'j' on the 'n'-th training example, this error, ej(n), is simply the difference between the desired target dj(n) and the network's actual output yj(n).

The goal of learning is to minimize this error across all outputs. Backpropagation achieves this by smartly adjusting the connection weights. It uses an optimization algorithm called 'gradient descent,' which essentially tells the network how to tweak each weight to move closer to the correct answer with each step.

e_j(n) = d_j(n) - y_j(n)

The change in each weight, wij, between neuron 'i' in one layer and neuron 'j' in the next, is proportional to the error at neuron 'j' and the output of neuron 'i'. This proportional factor includes a 'learning rate,' denoted by \eta , which controls how big each adjustment step is, ensuring the network learns steadily without overshooting.

Here, \deltaj(n) represents the 'local gradient' or 'error signal' for neuron 'j', and yi(n) is the output of the preceding neuron 'i' that feeds into 'j'. This formula reveals the elegant mechanics of how errors are used to inform weight updates.

\Delta w_{ij}(n) = \eta \delta_j(n) y_i(n)

For output nodes, calculating this error signal \deltaj(n) is straightforward. It involves the error ej(n) multiplied by the derivative of the activation function at that neuron's weighted input. This derivative tells us how sensitive the neuron's output is to changes in its input, which is crucial for determining how much a weight should change.

Where \phi'(vj(n)) is the derivative of the activation function \phi with respect to the weighted sum of inputs vj(n) at neuron j. This term ensures that weight adjustments are scaled appropriately based on the neuron's non-linear response.

\delta_j(n) = e_j(n) \phi'(v_j(n))

The real genius of backpropagation lies in how it handles hidden layers. For a hidden node, its \deltaj(n) isn't directly observable. Instead, it's calculated by propagating the error backward from the subsequent layers. Each error signal from a later neuron 'k' is multiplied by the weight wjk connecting 'j' to 'k', then summed up and multiplied by the derivative of 'j''s own activation function.

This equation elegantly shows how the 'blame' for an error in the output is distributed backward through the network, allowing every single weight, even in the deepest hidden layers, to be adjusted. This iterative process, repeating over many training examples, is how MLPs learn to perform incredibly complex tasks, forming the bedrock of modern AI.

\delta_j(n) = \phi'(v_j(n)) \sum_k \delta_k(n) w_{jk}

Article

Multilayer perceptron

In deep learning, a multilayer perceptron (MLP) is a kind of modern feedforward neural network consisting of fully connected neurons with nonlinear activation functions, organized in layers, notable for being able to distinguish data that is not linearly separable.

Modern neural networks are trained using backpropagation and are colloquially referred to as "vanilla" networks. MLPs grew out of an effort to improve on single-layer perceptrons, which could only be applied to linearly separable data. A perceptron traditionally used a Heaviside step function as its nonlinear activation function. However, the backpropagation algorithm requires that modern MLPs use continuous activation functions such as sigmoid or ReLU.

Multilayer perceptrons form the basis of deep learning, and are applicable across a vast set of diverse domains.

Timeline

Multilayer perceptron

• In 1943, Warren McCulloch and Walter Pitts proposed the binary artificial neuron as a logical model of biological neural networks. • In 1958, Frank Rosenblatt proposed the multilayered perceptron model, consisting of an input layer, a hidden layer with randomized weights that did not learn, and an output layer with learnable connections. • In 1962, Rosenblatt published many variants and experiments on perceptrons in his book Principles of Neurodynamics, including up to 2 trainable layers by "back-propagating errors". However, it was not the backpropagation algorithm, and he did not have a general method for training multiple layers.

• In 1965, Alexey Grigorevich Ivakhnenko and Valentin Lapa published Group Method of Data Handling. It was one of the first deep learning methods, used to train an eight-layer neural net in 1971.

• In 1967, Shun'ichi Amari reported the first multilayered neural network trained by stochastic gradient descent, was able to classify non-linearily separable pattern classes. Amari's student Saito conducted the computer experiments, using a five-layered feedforward network with two learning layers.

• Backpropagation was independently developed multiple times in early 1970s. The earliest published instance was Seppo Linnainmaa's master thesis (1970). Paul Werbos developed it independently in 1971, but had difficulty publishing it until 1982.

• In 1986, David E. Rumelhart et al. popularized backpropagation.

• In 2003, interest in backpropagation networks returned due to the successes of deep learning being applied to language modelling by Yoshua Bengio with co-authors.

• In 2021, a very simple NN architecture combining two deep MLPs with skip connections and layer normalizations was designed and called MLP-Mixer; its realizations featuring 19 to 431 millions of parameters were shown to be comparable to vision transformers of similar size on ImageNet and similar image classification tasks.

Mathematical foundations

Activation function

If a multilayer perceptron has a linear activation function in all neurons, that is, a linear function that maps the weighted inputs to the output of each neuron, then linear algebra shows that any number of layers can be reduced to a two-layer input-output model. In MLPs some neurons use a nonlinear activation function that was developed to model the frequency of action potentials, or firing, of biological neurons.

The two historically common activation functions are both sigmoids, and are described by

${\displaystyle y(v{i})=\tanh(v{i})~~{\textrm {and}}~~y(v{i})=(1+e^{-v{i}})^{-1}}$.

The first is a hyperbolic tangent that ranges from −1 to 1, while the other is the logistic function, which is similar in shape but ranges from 0 to 1. Here ${\displaystyle y{i}}$ is the output of the ${\displaystyle i}$th node (neuron) and ${\displaystyle v{i}}$ is the weighted sum of the input connections. Alternative activation functions have been proposed, including the rectifier and softplus functions. More specialized activation functions include radial basis functions (used in radial basis networks, another class of supervised neural network models).

In recent developments of deep learning the rectified linear unit (ReLU) is more frequently used as one of the possible ways to overcome the numerical problems related to the sigmoids.

Layers

The MLP consists of three or more layers (an input and an output layer with one or more hidden layers) of nonlinearly-activating nodes. Since MLPs are fully connected, each node in one layer connects with a certain weight ${\displaystyle w{ij}}$ to every node in the following layer.

Learning

Learning occurs in the perceptron by changing connection weights after each piece of data is processed, based on the amount of error in the output compared to the expected result. This is an example of supervised learning, and is carried out through backpropagation, a generalization of the least mean squares algorithm in the linear perceptron.

We can represent the degree of error in an output node ${\displaystyle j}$ in the ${\displaystyle n}$th data point (training example) by ${\displaystyle e{j}(n)=d{j}(n)-y{j}(n)}$, where ${\displaystyle d{j}(n)}$ is the desired target value for ${\displaystyle n}$th data point at node ${\displaystyle j}$, and ${\displaystyle y{j}(n)}$ is the value produced by the perceptron at node ${\displaystyle j}$ when the ${\displaystyle n}$th data point is given as an input.

The node weights can then be adjusted based on corrections that minimize the error in the entire output for the ${\displaystyle n}$th data point, given by

${\displaystyle {\mathcal {E}}(n)={\frac {1}{2}}\sum {{\text{output node }}j}e{j}^{2}(n)}$.

Using gradient descent, the change in each weight ${\displaystyle w{ij}}$ is

${\displaystyle \Delta w{ji}(n)=-\eta {\frac {\partial {\mathcal {E}}(n)}{\partial v{j}(n)}}y{i}(n)}$

where ${\displaystyle y{i}(n)}$ is the output of the previous neuron ${\displaystyle i}$, and ${\displaystyle \eta }$ is the learning rate, which is selected to ensure that the weights quickly converge to a response, without oscillations. In the previous expression, ${\displaystyle {\frac {\partial {\mathcal {E}}(n)}{\partial v{j}(n)}}}$ denotes the partial derivate of the error ${\displaystyle {\mathcal {E}}(n)}$ according to the weighted sum ${\displaystyle v{j}(n)}$ of the input connections of neuron ${\displaystyle i}$.

The derivative to be calculated depends on the induced local field ${\displaystyle v{j}}$, which itself varies. It is easy to prove that for an output node this derivative can be simplified to

${\displaystyle -{\frac {\partial {\mathcal {E}}(n)}{\partial v{j}(n)}}=e{j}(n)\phi ^{\prime }(v{j}(n))}$

where ${\displaystyle \phi ^{\prime }}$ is the derivative of the activation function described above, which itself does not vary. The analysis is more difficult for the change in weights to a hidden node, but it can be shown that the relevant derivative is

${\displaystyle -{\frac {\partial {\mathcal {E}}(n)}{\partial v{j}(n)}}=\phi ^{\prime }(v{j}(n))\sum {k}-{\frac {\partial {\mathcal {E}}(n)}{\partial v{k}(n)}}w{kj}(n)}$.

This depends on the change in weights of the ${\displaystyle k}$th nodes, which represent the output layer. So to change the hidden layer weights, the output layer weights change according to the derivative of the activation function, and so this algorithm represents a backpropagation of the activation function.