Skip to content

Neural Networks: The Honest Version

A neural network is a chain of matrix multiplications and nonlinearities trained by gradient descent. Its selling point is flexibility, and on quant data flexibility is a liability unless your data brings its own structure.

5 of 8 ~13 min

Neural Networks: The Honest Version

Neural networks are not magic. They are a chain of matrix multiplications and nonlinearities, trained by gradient descent to minimize a loss. The “intelligence” sits in the architecture choices, the data scale, and the regularization. Strip away the marketing and a neural network is a very flexible function with a very expensive training procedure.

That flexibility is both the appeal and the trap. Give it enough parameters and it is flexible enough to fit a giraffe. Whether it learns a giraffe or memorizes your training data is a matter of taste and regularization, and on quant data that distinction is very nearly the whole craft. This article covers the mechanics, and then why most successful quant ML still uses gradient boosting once you know them.

One Neuron

A single artificial neuron computes:

y=σ(w⋅x+b)y = \sigma(w \cdot x + b)

where xx is an input vector, ww is a weight vector, bb is a bias scalar, and σ\sigma is a nonlinear activation function. That is the entire neuron: take a linear combination of inputs, add a bias, squash through a nonlinearity. One of these solves linearly-separable classification problems. XOR it cannot, but that is a story for another article. The original perceptron (Rosenblatt, 1958) used a step function as σ\sigma; modern networks use smooth nonlinearities, and that single change is what makes them trainable by gradient descent.

Stack Them and You Have an MLP

Stack neurons in layers and you get a multilayer perceptron:

h(1)=σ(W(1)x+b(1))h^{(1)} = \sigma(W^{(1)} x + b^{(1)}) h(2)=σ(W(2)h(1)+b(2))h^{(2)} = \sigma(W^{(2)} h^{(1)} + b^{(2)}) y^=W(3)h(2)+b(3)\hat{y} = W^{(3)} h^{(2)} + b^{(3)}

Three layers here (input, one hidden, output), but you can have dozens or hundreds. Each layer is a matrix multiplication followed by a nonlinearity. The output layer depends on the task: sigmoid for binary classification, softmax for multiclass, a linear layer for regression.

Why depth? A shallow network with one hidden layer can approximate any continuous function on a compact domain, given enough neurons. That is the universal approximation theorem. The catch is that “enough” can be exponentially many for some functions. Deep networks, with more layers and fewer neurons each, learn hierarchical representations more efficiently: an image classifier learns edges, then textures, then object parts, then objects, layer by layer, where a one-hidden-layer network would have to learn all of it in one giant layer at absurd width.

Depth helps, though, without being miraculous. Going from 3 layers to 10 helps. Going from 50 to 100 on a fully-connected network over tabular data usually buys you nothing.

Activations: What Matters Is Whether They Saturate

The choice of σ\sigma matters more than people admit, and the selection criterion is basically one question: does it kill the gradient at large inputs?

Sigmoid, σ(x)=1/(1+e−x)\sigma(x) = 1 / (1 + e^{-x}), is smooth, bounded in (0,1)(0,1), and historically the default, and it carries one nasty property: for large ∣x∣|x| the gradient is essentially zero and training stalls. That is the vanishing gradient problem, and it is why sigmoid is rarely used in hidden layers anymore. Tanh is similar but bounded in (−1,1)(-1, 1) and zero-centered, which is slightly nicer for gradient flow, and it still saturates at large inputs.

ReLU, σ(x)=max⁡(0,x)\sigma(x) = \max(0, x), is the modern default: zero for negative inputs, linear for positive, no saturation on the positive side, and cheap to compute. Its cost is a different failure mode: a neuron whose input is consistently negative has a permanently zero gradient and never updates. That is the “dying ReLU” problem, mitigated by leaky ReLU (max⁡(0.01x,x)\max(0.01x, x)) and careful initialization. GELU and SwiGLU are the smoother variants used in modern transformers, with slightly better optimization properties and marginally better accuracy; worth knowing if you ever fine-tune a language model, and overkill for tabular quant data.

For quant ML on tabular features, ReLU is fine. Spend your time on data quality and regularization, not on activation choice.

The Forward Pass Is Essentially Free

The forward pass runs an input through the layers in order and stores the intermediate values for backpropagation. For a network with LL layers, that is LL matrix multiplications and LL nonlinearities, which takes microseconds to milliseconds for a typical MLP on a modern GPU.

For scale: with a batch of size BB, DD input features, and hidden width HH, the first layer costs B×D×HB \times D \times H multiply-adds. At B=256,D=100,H=64B=256, D=100, H=64 that is 1.6 million multiply-adds, against a modern GPU doing trillions per second. Whatever training costs you, it is not the forward direction.

Backpropagation Is the Chain Rule

Backpropagation is reverse-mode automatic differentiation applied to a neural network’s loss. It computes the gradient of the loss with respect to every parameter in one pass at roughly the cost of a forward pass. Conceptually it is three steps:

  1. Forward: compute predictions y^\hat{y} and loss L(y,y^)L(y, \hat{y}).
  2. Backward: starting from the loss, apply the chain rule recursively to compute ∂L/∂W(ℓ)\partial L / \partial W^{(\ell)} for every layer ℓ\ell.
  3. Update: W(ℓ)←W(ℓ)−α⋅∂L/∂W(ℓ)W^{(\ell)} \leftarrow W^{(\ell)} - \alpha \cdot \partial L / \partial W^{(\ell)}, where α\alpha is the learning rate.

The math is calculus. The implementation is automated by every modern framework (PyTorch, JAX, TensorFlow), and you will almost never write it by hand. But knowing that it is the chain rule, and that it is exact rather than approximate, is what separates someone who understands what they are training from someone who is turning a crank. (Goodfellow, Bengio, Courville, Deep Learning, Ch. 6. ISBN 978-0262035613.)

The Training Loop and the Three Knobs Around It

The training loop is short and you will write it hundreds of times:

for epoch in range(num_epochs):
    for batch in dataloader:
        predictions = model(batch.x)
        loss = loss_fn(predictions, batch.y)
        loss.backward()
        optimizer.step()
        optimizer.zero_grad()

That is it. Forward, compute loss, backward, update, reset gradients, repeat. The rest is bookkeeping, logging, validation, and checkpoints.

What actually requires judgment are the three knobs around that loop. The first is the optimizer. SGD with momentum is the classical default, slow but stable, with good final convergence on well-tuned problems. Adam (Kingma & Ba, 2014) is the practical default, with adaptive per-parameter learning rates, faster than SGD on most problems and less stable over long runs. AdamW is Adam with decoupled weight decay, generalizes better than vanilla Adam, and is the current default for training transformers. RMSprop is similar to Adam and slightly older, still used in some RL contexts. For quant ML, Adam is the safe choice; start the learning rate at 10−310^{-3} and adjust down.

The second is the learning rate schedule, because the rate you start with is rarely the one you should finish with. Constant is simplest, works, and is rarely optimal. Step decay multiplies the rate by 0.1 every kk epochs and is effective and simple. Cosine annealing decays smoothly along a cosine curve and is the default in many modern frameworks. Warmup plus decay starts small, ramps up over a few hundred steps, then decays, and is used in transformer training. For Adam-based MLP training, cosine annealing or step decay typically lifts final performance noticeably over a constant rate, though the size of the lift depends on the problem and is not an order-of-magnitude effect. Arithmion’s train_mlp() takes an lr_schedule argument for this.

The third is normalization layers, which modern networks need in order to train stably at all. Batch normalization normalizes activations across the batch dimension: for each feature in a layer’s output, subtract the batch mean, divide by the batch standard deviation, then apply a learned scale and shift. It stabilizes training, allows higher learning rates, and acts as mild regularization on the side. Layer normalization goes the other way, normalizing across the feature dimension within each example; transformers use it because it is independent of batch size, which matters when batches are small or sequence lengths vary. For MLPs on tabular data, batch normalization is standard. For transformers, layer normalization is. Both are effectively required for modern architectures.

That is the mechanics, and the mechanics are not hard. The next section is.

Why Neural Networks Are Hard in Quant

This is the part quant vendors skip. Neural networks work wonderfully on images, text, and speech. On tabular financial data they are routinely beaten by gradient boosting, for four reasons that reinforce each other.

The first is data scarcity. ImageNet has 14 million labeled images and Common Crawl has trillions of tokens; a 20-year panel of US equities has, generously, 5 million firm-day observations, before you discount for survivorship, delistings, and the fact that those observations are heavily correlated with each other. Neural networks are sample-hungry. They want more data than you have.

The second is overfitting, which is the same coin from the other side. A 5-layer MLP with 100 hidden units has roughly 50,000 parameters. Train it on 10,000 samples against a target with an R2R^2 of 0.5%, which is typical for return prediction, and your parameter count vastly exceeds the amount of signal in the data. The result is not a model that learns slowly. It is a model that memorizes noise.

The third is non-stationarity. Patterns in financial data change; the relationship between value stocks and returns in 2007 is not the relationship in 2020. A neural network learns whatever you gave it and has no idea the world moved. Rolling retraining and regime features help, but the challenge is fundamental. Trees handle it slightly better because they partition the feature space and can adapt locally.

The fourth is interpretability. A linear model tells you its coefficients. A decision tree tells you its splits. A neural network gives you a SHAP plot, which is useful but never a complete account of why one specific prediction came out the way it did. For risk management and compliance, that is not academic fussiness. It is whether the thing can go live.

So Assume It Will Overfit

On quant data it will. These are the levers, in rough order of effectiveness:

  1. More data: the only true fix. If you cannot get more, manufacture some via augmentation.
  2. Dropout: 0.2 to 0.5 in dense layers, active during training only.
  3. Weight decay (L2 regularization on weights, decoupled in AdamW): small values like 10−410^{-4} to 10−210^{-2}.
  4. Early stopping: stop when validation loss stops improving.
  5. Smaller architecture: fewer layers, fewer neurons per layer.
  6. Data augmentation: noise injection, mixup, feature dropout.
  7. Batch normalization: mild regularization as a side effect.

Almost every practical neural network in quant uses the first four. The rest are situational. Note what the ordering itself is saying: the top two are not modeling tricks. They are data and randomness.

When Neural Networks Do Earn Their Place

What the problems above have in common is that tabular data offers no structure to exploit. So the answer follows the same line: neural networks win when the data carries structure gradient boosting cannot chew on.

Images in alternative data are the cleanest case: satellite imagery of parking lots, store receipts, agricultural fields, where CNNs have no real competition (see our alternative data series for examples). Text is the same story: earnings calls, news headlines, 10-K filings, social media, where transformers are state of the art. Third are time series with strong temporal dependencies, where LSTMs, temporal convolutional networks, and transformers all have a role in limit order book modeling and high-frequency signals. Fourth are multi-asset and cross-asset signals: when the input holds many parallel sequences, such as cross-sectional stock features or multi-currency pairs, attention mechanisms help. Fifth is representation learning, using autoencoders and contrastive learning to do feature engineering on messy alternative data.

One more case deserves its own paragraph, because it is one of the few genuine advantages neural networks have on tabular data: high-cardinality categoricals. Sector codes, ticker symbols, and country identifiers can have hundreds or thousands of unique values, and one-hot encoding blows up the input dimensionality. An embedding layer instead learns a dense low-dimensional vector in Rd\mathbb{R}^d for each category, updated by backpropagation during training, so categories that are useful in similar contexts end up with similar embeddings. For ticker symbols, learned embeddings can capture sector, size, and style relationships implicitly, as an alternative to explicit cross-sectional features. LightGBM and XGBoost can sort categories by mean target, but they cannot learn semantic embeddings. That is a real capability gap, not a marketing line.

For pure tabular signals (price ratios, technical indicators, fundamentals, sector dummies), gradient boosting is usually better and faster. This is not a guess. It is the finding that keeps recurring across tabular Kaggle competitions and published quant research.

If You Do Need One on Tabular Data, Start Here

If you genuinely need a neural network on tabular data, perhaps to combine with embeddings or as one piece of a larger system, this is a reasonable starting architecture:

Input (numeric features, standardized)
    ↓
Dense(256, ReLU) + BatchNorm + Dropout(0.3)
    ↓
Dense(128, ReLU) + BatchNorm + Dropout(0.3)
    ↓
Dense(64, ReLU) + Dropout(0.2)
    ↓
Dense(1, linear)  # regression output

A few notes. Batch normalization stabilizes training by normalizing layer inputs and is almost always helpful. Dropout in the 0.2 to 0.5 range regularizes aggressively, and this value needs careful tuning, since too much of it underfits outright. Standardize numeric inputs to zero mean and unit variance before feeding them in, because neural networks are far more sensitive to feature scaling than gradient boosting is. Route categorical features through embedding layers, where a categorical with kk levels gets an embedding of dimension min⁡(50,(k+1)//2)\min(50, (k+1)//2) that the network learns during training.

A small MLP with this structure has roughly 50,000 parameters: enough capacity for a moderately complex signal, not enough to memorize millions of examples, and on quant data that second half is the point. Arithmion’s SDK packages it as a one-liner, train_mlp(hidden_layers=[256, 128, 64], dropout=0.3, learning_rate=1e-3), handling standardization and categorical embeddings along the way.

Two other entry points exist in the SDK: train_lstm() for sequence prediction on time-series features, where the overfitting risks above apply in full, and train_transformer(), a small transformer for sequence-to-sequence tasks that is probably overkill for most quant use cases but is there when it is not. For tabular signals, train_lightgbm() is what you reach for first.

So What Do You Do

If you are a quant researcher opening a new project on tabular data, use LightGBM or XGBoost, train it properly, and then try to beat it with feature engineering rather than with a neural network. That advice sounds conservative, but it carries a hard diagnostic: if you cannot beat GBM with feature engineering, the problem is not the model. The signal is not there. Reaching for a more complex model only delays the moment you find that out.

Only when you have alternative data (satellite images, transcripts, tick data) do neural networks go from optional to necessary. That is when the mechanics in the first half of this article start paying for themselves. But that is a different problem and a different article series.

References

  • Goodfellow, I., Bengio, Y., Courville, A., Deep Learning, Ch. 6–8. ISBN 978-0262035613.
  • Bishop, C. M., Pattern Recognition and Machine Learning, Ch. 5. ISBN 978-0387310732.
  • Hastie, Tibshirani, Friedman, The Elements of Statistical Learning, 2nd ed., Ch. 11 (Neural Networks). ISBN 978-0387848570.
  • Rosenblatt, F. (1958). “The Perceptron: A Probabilistic Model for Information Storage and Organization in the Brain.”
  • Kingma, D. P., Ba, J. (2014). “Adam: A Method for Stochastic Optimization.”