Multilayer Perceptrons
A multilayer perceptron, or MLP, is the standard dense feed-forward neural network: affine maps followed by activation functions. Information flows forward from inputs through hidden layers to outputs; there is no recurrent hidden state and no loop over sequence time.
“Feed-forward network” is the broader graph description: the computation has directed layers and no cycles. An MLP is the dense version most people mean in deep-learning architectures. In transformer papers, FFN usually means a position-wise MLP sublayer, not a separate sequence model.
The MLP computation
For a two-layer MLP,
Here is the input vector or batch, and are learned parameters, is a nonlinearity such as ReLU or GELU, is the hidden representation, and is the output. The nonlinearity is essential: without it, two affine layers collapse into one affine map.
Transformer use
In a transformer, the feed-forward network is usually a position-wise MLP:
The same parameters are applied independently to every token position . Self-attention mixes information across positions; the FFN mixes and reshapes features inside each token vector. Many transformer FFNs first expand the hidden width, apply a nonlinearity such as GELU or SwiGLU, and then project back to the model width.
Worked example
For one token vector , a transformer FFN might map
The middle layer gives the model more feature capacity at that position. It can create nonlinear combinations such as “this token is a verb in a question” or “this patch has a vertical edge and high contrast” after attention has supplied context.
Caveats
“Feed-forward” describes the information-flow graph, not the training algorithm. MLPs are still trained with backpropagation. Dense MLPs also ignore spatial, temporal, or relational structure unless the input representation or surrounding architecture supplies it. That is why CNNs, recurrent networks, attention, and transformers add stronger structure around MLP blocks.
References
Nav