The Multilayer Perceptron
The multilayer perceptron is the plain vanilla neural network, a stack of weighted sums with each one bent by a simple nonlinear function before being passed on. That bending is the whole trick, and it is what lets the model learn the "it depends" relationships a straight line cannot express.
Prerequisites: Logistic Regression, Linear Algebra for Quants
A linear model gives every input a fixed importance. Momentum is worth , value is worth , and that stays true on quiet days, panicked days, and every day in between. That rigidity is often fine — and it is exactly why linear models are hard to beat. But it makes some perfectly ordinary statements impossible to write down. "Momentum works, unless volatility is high" is not a straight line. Neither is "this signal helps small caps and hurts large caps". Every relationship where the effect of one input depends on another is out of reach.
You could hand-build the interaction terms, but you have to know in advance which ones matter. A multilayer perceptron finds them for you.
The analogy: a desk of junior analysts
Picture a research desk. Every junior analyst sees the same raw inputs, but each one cares about a different combination of them. Analyst A watches "momentum minus volatility". Analyst B watches "value plus liquidity". Crucially, each one only speaks up when their own number crosses a threshold — below it they stay silent and contribute nothing.
The portfolio manager does not look at the raw data at all. She takes a weighted vote of whichever analysts happened to speak.
Nothing in that room is sophisticated. Every analyst computes a weighted sum and applies a threshold; the PM computes a weighted sum of what she hears. But because analysts go quiet in some market conditions and loud in others, the PM's final view is not a fixed formula of the inputs. Its shape changes with the situation. That is a multilayer perceptron, and the analysts are its hidden layer.
One unit
A single artificial neuron takes inputs , multiplies each by a weight (how much this unit cares about that input), adds a bias (its baseline, equivalently the negative of its threshold), and passes the result through an activation function :
In words: score the inputs, then bend the score. The first equation alone is just linear regression. The second one, , is what makes everything else possible.
Two activations cover most of what you will see. ReLU is : pass positive scores through untouched, output zero for anything negative. That is literally the analyst who stays silent. The logistic (sigmoid) is , an S-shape that squashes any score into the range 0 to 1, useful when you want a probability at the end.
Drag the steepness below to see the sigmoid go from a gentle slope to a near-vertical switch. A steep activation is close to a hard yes/no gate; a shallow one blends smoothly.
Stacking units into layers
Put several units side by side, all reading the same inputs, and you have a layer. Feed that layer's outputs into another layer and you have a multilayer perceptron. Written compactly for a two-layer network:
In words: the first line says every hidden unit scores the raw inputs and bends the result; the second line says the output is an ordinary weighted sum of those bent scores. is a table of weights with one row per hidden unit, is the vector of what the hidden units said, and is the prediction.
Worked example 1: one forward pass by hand
Two standardised inputs: momentum and volatility (so vol is below average). Two ReLU hidden units, one sigmoid output.
Hidden unit 1 has weights and bias :
That is positive, so ReLU passes it: . This unit likes high momentum and dislikes high volatility, and today both conditions favour it, so it speaks loudly.
Hidden unit 2 has weights and bias :
Negative, so ReLU clamps it: . This unit stays silent today, and therefore contributes exactly nothing to the answer.
Output with weights and bias :
A 77% chance of an up move. Note what happened: the second unit was switched off, so today the network behaved like a different, simpler model than it would on a high-volatility day. Same weights, different active pathway.
Worked example 2: the thing a line cannot do
Two flags: is 1 when momentum is positive, is 1 when volatility is low. The target pays 1 when exactly one flag is on — the classic XOR pattern.
| target | ||
|---|---|---|
| 0 | 0 | 0 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 1 | 0 |
No straight line can do this. A linear rule fires when . It must be positive at and , so adding those two conditions gives . It must be negative at and , and adding those gives . The same quantity cannot be both. No weights exist, ever.
Now two ReLU hidden units. Let and , with output :
- : , , output . ✓
- : , , output . ✓
- : , , output . ✓
- : , , output . ✓
Exact, with two hidden units and six numbers. The second unit only wakes up when both flags are on, and its job is to cancel the first unit's enthusiasm. That cancellation is the interaction term you never had to specify.
What this means in practice
Add more hidden units and the boundary the network can draw gets more intricate. The The Universal Approximation Theorem says one wide enough hidden layer can approximate essentially any continuous function — but "can represent" is not "will find from noisy data". Financial signals have low signal-to-noise, so an MLP flexible enough to fit the training set will happily fit the noise too. The explorer below shows the trade-off directly: turn up flexibility and watch the boundary contort around individual points.
In practice the inputs must be standardised (a unit weighing raw price against raw volume is hopeless), the weights are found by Stochastic Gradient Descent using gradients from Backpropagation, and depth is usually kept modest on tabular financial data — two or three hidden layers, heavily regularised, is a typical honest setup. Where MLPs genuinely earn their keep is when interactions matter and you cannot name them in advance.
Three choices are yours to make. Width is how many units per layer, which controls how many distinct "analysts" the model can hire. Depth is how many layers, which lets later units build on combinations that earlier units already found rather than starting from the raw inputs each time. And the output layer is not bent at all for a regression target — you want a plain weighted sum that can take any value — but gets a sigmoid for a two-way classification, so the answer arrives as a probability. Get the last one wrong and the model cannot express the answer you asked for, no matter how well the rest trains.
The activation function is the entire point. Weighted sums are linear; a stack of linear maps is still one linear map. Bending each layer's output — even with something as crude as — is what turns a stack of averages into a model that can say "it depends".
The classic confusion: people assume more layers means more expressive power. Without an activation function it means nothing at all. If is the identity, then is just for — a hundred-layer network collapses algebraically into one linear regression with more parameters and no more power. Depth without nonlinearity buys you a slower way to fit a straight line.
Related concepts
Practice in interviews
Further reading
- Goodfellow, Bengio & Courville, Deep Learning, ch. 6
- Bishop, Pattern Recognition and Machine Learning, ch. 5