A multilayer perceptron, or MLP, is one of the most fundamental neural network architectures in machine learning. It consists of an input layer, one or more hidden layers, and an output layer, with every neuron in each layer connected to every neuron in the next. Despite being one of the oldest neural network designs, the MLP remains widely used and surprisingly competitive for tasks ranging from tabular data classification to time series forecasting, and its basic structure serves as a building block inside more complex architectures like transformers.
How the Architecture Works
An MLP is a type of feedforward neural network, meaning information flows in one direction: from input to output. There are no loops or cycles. The input layer receives raw data, each hidden layer transforms that data through weighted connections and activation functions, and the output layer produces the final prediction. The term “fully connected” (sometimes called “dense”) describes the wiring: every neuron in one layer sends its signal to every neuron in the next layer. Each of those connections carries a weight, which is a number the network learns during training.
A single neuron does something straightforward. It takes all its incoming signals, multiplies each by its connection weight, adds a bias term, and then passes the result through an activation function. The activation function is what introduces nonlinearity, which is the whole reason MLPs can learn complex patterns rather than just fitting straight lines through data. Without activation functions, stacking multiple layers would collapse into the equivalent of a single linear transformation, and the network would be no more powerful than simple linear regression.
The depth and width of an MLP are its two main architectural choices. Width refers to how many neurons sit in each hidden layer. Depth refers to how many hidden layers the network has. A wider layer can capture more features at a given level of abstraction, while a deeper network can learn more hierarchical representations. In practice, choosing the right combination is more art than science and depends heavily on the problem at hand.
Choosing an Activation Function
The activation function applied inside each hidden-layer neuron has a real effect on how well the network learns. The three most common choices are the sigmoid function, the hyperbolic tangent (tanh), and the rectified linear unit (ReLU). Sigmoid squashes values between 0 and 1, tanh squashes them between −1 and 1, and ReLU simply outputs zero for any negative input and passes positive values through unchanged.
Each has trade-offs. Sigmoid was the historical default but tends to cause problems in deep networks because its gradients shrink rapidly as values move away from zero, making it harder for the network to learn in earlier layers. Tanh shares a similar shape but centers its output around zero, which generally helps learning proceed more smoothly. ReLU became the most popular choice over the past decade because it is computationally cheap and avoids some gradient-shrinking issues, though it has its own failure mode: neurons can “die” and permanently output zero if they land in the negative region.
A study comparing these three activation functions in an MLP used for time series forecasting found that tanh produced the lowest prediction error, outperforming both sigmoid and ReLU on the same dataset.1AIP Conference Proceedings. Activation functions performance in multilayer perceptron for time series forecasting That does not mean tanh always wins. The best activation function depends on the task, the data, and how the rest of the network is configured. ReLU and its variants (leaky ReLU, GELU, swish) dominate in most deep learning applications today, while tanh remains a strong choice for certain forecasting and sequence tasks.
Training With Backpropagation
Training an MLP means adjusting all of its weights so that the network’s predictions get closer to the correct answers. This happens through a process called backpropagation combined with gradient descent. The network makes a prediction, a loss function measures how wrong that prediction is, and then the error signal is propagated backward through the network. At each connection, the algorithm calculates how much that particular weight contributed to the error and nudges it in the direction that reduces the loss. Repeat this across thousands or millions of examples, and the network gradually improves.
The loss function you choose depends on the task. For classification, cross-entropy loss has been the standard for years because it directly penalizes confident wrong predictions. However, research comparing cross-entropy against the simpler squared-error loss across tasks in natural language processing, speech recognition, and computer vision found that squared-error loss performed comparably or even better in the majority of NLP and speech experiments.2arXiv. Evaluation of Neural Architectures Trained with Square Loss vs Cross-Entropy in Classification Tasks The widely held assumption that cross-entropy is always the better choice may not hold as universally as practitioners believe.
Optimizers and Learning Rate
Gradient descent comes in many flavors, and the optimizer you pick determines how the weights get updated at each step. Basic stochastic gradient descent (SGD) updates weights using a fixed-size step in the direction that reduces the loss. Variants like momentum SGD add a kind of inertia so the optimizer does not get stuck in shallow dips. More sophisticated optimizers like Adam, RMSProp, and newer ones like Lion and Yogi adapt the step size for each weight individually based on the history of its gradients.
A comparative study across the MNIST and CIFAR-10 benchmarks showed that plain SGD with a well-tuned learning rate achieved the highest test accuracy on MNIST at about 99.1%, while momentum SGD led on the more complex CIFAR-10 dataset with roughly 73% test accuracy. Adam performed well on both but did not dominate either. Newer optimizers like Lion showed strong stability at very low learning rates but struggled at higher ones.3International Journal of Innovative Science and Research Technology. Comparative Study of Deep Learning Optimizers: SGD, Momentum SGD, RMSProp, AMSGrad, Adam, Yogi, and Lion The practical takeaway is that no single optimizer is best for every problem. SGD with momentum remains a surprisingly strong baseline when you have time to tune the learning rate, while Adam is often the safer default when you want reasonable performance without extensive tuning.
In domain-specific applications, optimizer choice can also interact with the activation function. An MLP trained with momentum gradient descent and a sigmoid activation achieved the best turbidity predictions from satellite imagery in one environmental study, outperforming other optimizer-activation combinations on that particular regression task.4Hydrology. Performance Evaluation of Gradient Descent Optimizers in Estuarine Turbidity Estimation with Multilayer Perceptron and Sentinel-2 Imagery
The Vanishing Gradient Problem
One of the oldest headaches in training deep MLPs is the vanishing gradient problem. When a network has many layers and uses sigmoid or tanh activations, the gradients passed backward during training shrink exponentially as they travel through each layer. By the time the error signal reaches the earliest layers, it can be so tiny that those layers effectively stop learning. This is a direct consequence of how the chain rule in calculus works during backpropagation: multiplying many small numbers together yields an even smaller number.5Advance in Information Technology and Computer Science. Gradient Disappearance Problem of Deep Learning Model and New Optimization Strategy
For years, the standard advice was to simply avoid sigmoid activations in deep networks and use ReLU instead. But recent research has shown that the problem is not inherent to sigmoid itself. Rather, how you initialize the weights matters enormously. A study found that if you set the initial weights to have a negative mean that scales inversely with the number of neurons in each layer, the vanishing gradient problem largely disappears even in networks with 10 or 15 hidden layers using sigmoid activations.6PubMed. Successfully and efficiently training deep multi-layer perceptrons with logistic activation function simply requires initializing the weights with an appropriate negative mean This is a useful reminder that training failures often trace back to initialization and hyperparameter choices rather than fundamental architectural limitations.
For ReLU networks, the most commonly recommended initialization scheme is Kaiming initialization, which sets the initial weight variance based on the number of incoming connections to each neuron. Controlled comparisons confirm that Kaiming initialization converges faster and more stably than the older Xavier initialization when used with ReLU.7arXiv. Weight Initialization and Variance Dynamics in Deep Neural Networks and Large Language Models Other widely used countermeasures include batch normalization, which re-centers and re-scales activations within each layer during training, and residual connections, which let gradients skip over layers to flow more directly backward.
Where MLPs Are Commonly Used
MLPs show up across a wide range of applications, but they tend to be strongest in certain categories. Tabular data, meaning structured rows-and-columns datasets like you would find in a spreadsheet, is perhaps the most traditional MLP territory. Customer churn prediction, credit scoring, medical diagnosis from lab values, and price estimation are all classic MLP tasks. The fully connected architecture handles mixed feature types (numerical and categorical) reasonably well, and for many of these problems the datasets are not enormous, so the MLP’s relative simplicity is a plus.
Time series forecasting is another area where MLPs remain competitive. A lightweight MLP-based model called TSP, built around a mechanism for capturing both cross-variable dependencies and local time patterns, outperformed more complex state-of-the-art methods across 16 benchmarks for long-term forecasting and traffic prediction, while reducing training time on CPU by over 95%.8Knowledge-Based Systems. A lightweight multi-layer perceptron for efficient multivariate time series forecasting Results like these challenge the assumption that you always need a transformer or recurrent network for sequence data.
MLPs also serve as essential components within larger systems. Inside a transformer model, the feed-forward network in each block is literally a two-layer MLP applied to each position independently. Research measuring how these internal MLP blocks behave in models like GPT-2 found that some blocks operate almost linearly while adjacent blocks are highly nonlinear, and this variation is a learned property of each trained block rather than something set by the architecture itself.9arXiv.org. How Linear Is a Transformer Feed-Forward Block? Per-Block Linear Recoverability Is Learned, Not Architectural In other words, the MLP blocks inside a transformer learn to specialize: some function as simple relays while others perform complex transformations.
MLPs Versus Tree-Based Models on Tabular Data
If you work with structured tabular datasets, you have probably heard that gradient-boosted decision trees (like XGBoost and CatBoost) are hard to beat. This reputation is well-earned. Benchmarking studies consistently show that tree-based models remain the top performers on medium-sized tabular datasets of around 10,000 samples, even without accounting for their much faster training speed.10NeurIPS Proceedings. MLP Model: Architecture, Training, and Common Use Cases A separate study found that tree-based methods handle skewed distributions, heavy-tailed features, and other irregularities in tabular data much more gracefully than neural networks do.11NeurIPS Proceedings. MLP Model: Architecture, Training, and Common Use Cases
That said, the gap has been closing. More recent deep learning methods designed specifically for tabular data, such as TabPFN, have shown strong results, with one benchmarking analysis placing TabPFN alongside CatBoost and XGBoost at the top of the rankings.12arXiv. Is Deep Learning finally better than Decision Trees on Tabular Data? – Section: 5.1 (R1+R2) Quality metrics The practical guidance for most practitioners is still straightforward: if your data is tabular and medium-sized, start with a gradient-boosted tree model. Reach for an MLP or more specialized neural architecture when you have very large datasets, when the task benefits from end-to-end learning with other modalities (like combining tabular features with images or text), or when you need to integrate the model into a larger neural pipeline.
Overfitting and Regularization
Because an MLP’s fully connected architecture creates an enormous number of learnable parameters, overfitting is a constant concern. A network with two hidden layers of 512 neurons each, operating on a modest input, can easily have hundreds of thousands of weights. Given enough capacity, the network will memorize training data rather than learning patterns that generalize.
Several techniques help keep this in check. Dropout randomly deactivates a fraction of neurons during each training step, forcing the network to learn redundant representations rather than relying on any single pathway. Weight decay (also called L2 regularization) penalizes large weight values, encouraging the network to favor simpler solutions. Early stopping monitors performance on a validation set and halts training when the network starts performing worse on unseen data. Batch normalization, in addition to helping with gradient flow, also has a mild regularizing effect. In practice, most well-trained MLPs use some combination of these techniques. The specific mix and strength depend on dataset size, network depth, and how much capacity the model has relative to the complexity of the task.
MLP-Only Vision Models
For most of deep learning’s history, convolutional neural networks (CNNs) were considered essential for image tasks, and transformers more recently joined them. MLPs were thought to lack the right structural priors for vision because they do not inherently understand spatial relationships the way convolutions do. Researchers at Google challenged this assumption with MLP-Mixer, an architecture that uses only MLPs and no convolutions or attention mechanisms. MLP-Mixer works by splitting an image into patches and alternating between two types of MLP layers: one that mixes information across features within each patch, and another that mixes information across patches spatially. When trained on large datasets or with modern regularization, MLP-Mixer achieved competitive image classification accuracy at a cost comparable to leading CNN and transformer models.13arXiv. MLP-Mixer: An all-MLP Architecture for Vision
A follow-up architecture called AS-MLP refined this idea by focusing on local feature interactions. Instead of mixing all spatial positions globally, AS-MLP shifts feature channels along horizontal and vertical axes, giving the MLP access to local neighborhoods in a way that mimics the receptive field of a CNN, but without using convolution operations.14arXiv. AS-MLP: An Axial Shifted MLP Architecture for Vision These MLP-only vision models demonstrate something important: the perceived limitations of MLPs often come down to how they are applied rather than what they are fundamentally capable of. With the right data preprocessing and training regime, the simple fully connected structure can handle tasks that once seemed to require specialized architectures.
A related insight from research probing vision architectures is that MLPs lack any built-in inductive bias for visual structure, which makes them a useful test bed for studying what neural networks learn from data alone versus what they get for free from architectural design.15NeurIPS Proceedings. MLP Model: Architecture, Training, and Common Use Cases When an MLP succeeds on vision tasks, it suggests the training data and regularization were sufficient to teach the model spatial patterns from scratch.
Compressing MLPs for Deployment
Once an MLP is trained, deploying it in production often means making it smaller and faster. Two main techniques dominate this space: pruning and quantization. Pruning removes weights (or entire neurons) that contribute little to the network’s output, effectively thinning out the connections. Quantization reduces the numerical precision of the remaining weights, for example converting them from 32-bit floating point to 8-bit integers, which shrinks memory usage and speeds up computation on hardware that supports lower-precision arithmetic.
Both techniques have been wildly successful in practice, but theoretical understanding of why they work so well has lagged behind. Recent theoretical work on MLP compression has established rigorous bounds showing that pruned and quantized subnetworks of MLPs can maintain competitive performance relative to the full original network.16Annual Conference Computational Learning Theory. Theoretical Compression Bounds for Wide Multilayer Perceptrons This matters for real-world deployment because it means you can often cut an MLP’s size dramatically, sometimes by 90% or more, without meaningful loss in accuracy. For applications on mobile devices, embedded systems, or anywhere inference latency and power consumption matter, compression is what makes MLPs practical.
When to Pick an MLP Over Something Else
Given the zoo of neural architectures available today, knowing when an MLP is the right choice saves time and computational resources. A few guidelines hold up well across domains.
If your input data is a fixed-length vector of features with no inherent spatial or sequential structure, an MLP is a natural starting point. Tabular business data, sensor readings summarized as feature vectors, and precomputed embeddings from other models all fit this category. You do not need the overhead of attention layers or convolutions when the input has no spatial grid or temporal ordering to exploit.
If speed and simplicity matter more than squeezing out the last fraction of a percent of accuracy, an MLP is often the right call. Its forward pass is just a series of matrix multiplications and activation functions, which makes it fast to train, fast to run at inference time, and easy to debug. There is no complex memory mechanism to inspect, no attention head to visualize. When a model will be retrained frequently or needs to make predictions in milliseconds, this simplicity becomes a genuine advantage.
Conversely, if your data has strong spatial structure (images, video, 3D point clouds), a CNN or vision transformer will usually outperform a basic MLP with far less data. If your data is sequential and order matters (language, speech, music), transformers and recurrent networks encode that structure more efficiently. And as noted above, for medium-sized tabular datasets where you do not need end-to-end learning with other modalities, gradient-boosted trees still tend to win. The MLP occupies a sweet spot: powerful enough for a huge range of problems, simple enough to serve as a reliable baseline, and flexible enough to embed inside more complex systems when needed.