Multilayer perceptrons
What it is
An MLP alternates fully connected layers and nonlinearities. Every output unit in a dense layer can use every input feature, so the model can learn rich interactions among a fixed set of values. It has no built-in notion of image locality, token order, or graph structure; those properties must be encoded in the input or supplied by a different architecture. Width controls how many features a layer can represent, while depth lets the network compose those features into more complex functions.
Why it matters
MLPs are the right baseline for fixed-length vectors and the feed-forward sublayer inside Transformers. They are usually the wrong inductive bias for raw images and long sequences because they do not share weights across spatial positions or time. A simple MLP baseline is still valuable: if a specialised model cannot beat it honestly, the extra complexity has not earned its cost.
In the real world: Still used for predictions from tabular data and inside recommendation systems.
Visual example
Deep learningEvery dense layer mixes all features from the previous layer.
import torch.nn as nn
mlp = nn.Sequential(
nn.Linear(64, 128), nn.ReLU(),
nn.Linear(128, 64), nn.ReLU(),
nn.Linear(64, 3), # logits; no softmax here
)
mlp(x).shape # (batch, 3) for x of shape (batch, 64)Flattening an image into an MLP and interpreting failure as 'neural networks do not work'. The model discarded the spatial structure that a CNN can exploit with far fewer parameters.