Topic: ml-fundamentals

The building blocks every network is assembled from, followed through one training step: initialisation, activations and normalisation, the loss, the update, regularisation and measurement, and what to do when training goes wrong: a map of the nine pages that own them, the comparisons across them, and the tools that span them. Sources are linked inline; data as of 3 October 2026, map rebuilt 24 October 2026, split layout and Fig. 1 added 10 November 2026. Reading: 28 min, plus 1 in closed details.

One training step, start to finish

Every network learns by repeating one step, and every building block in this topic is a choice made at exactly one of its seven moments; the choices come in matched sets because four threads tie the moments together. The step: take a batch, push it forward, score it with a loss, send the error backward for a gradient on every weight, update the weights, keep them from fitting noise (regularise), and measure on data the step did not see.

Fig. 1 runs one real step of a small network (16 layers of width 64, a batch of 32, 10 classes) through the seven moments, with the numbers each produces. Switch the recipe to run the same batch the classic way. Predict first: which recipe starts nearer the chance loss ln 10 = 2.30?

  1. 1 · Data, init. A batch of 32 inputs of 64 numbers arrives (the glass plate). The 541,312 weights are drawn with variance 1/fan-in, σ = 0.125 into each SwiGLU block, and each block's output matrix is scaled down a further 1/√16 = 0.25 (GPT-2's rule), σ = 0.019, so 16 residual additions do not inflate the stream. Section 1
  2. 2 · Forward. Each block: RMSNorm the stream, a SwiGLU feed-forward (64 → 176 → 64), add the result back. The norm sits on the branch, not on the stream, and the branches start small, so the spread of the stream (one bar per layer) only drifts from 1.04 to 1.20. Section 2
  3. 3 · Loss. Cross entropy, the batch mean of −log p(right class): 2.60, close to the chance level ln 10 = 2.30 (the glass sheet), since a final RMSNorm keeps the head's input at unit scale. Section 3
  4. 4 · Backward. Backpropagation hands each layer the gradient from above (one bar per layer, layer 16 back to layer 1). The global gradient norm is 5.50, and the recipe clips any norm above 1.0 down to 1.0, here by a factor of 0.182. First against last layer: 1.45 against 1.17. Section 4
  5. 5 · Update. AdamW: on the first step its bias-corrected averages are the gradient itself, so each weight moves by the learning rate, 3 × 10−3, times the sign of its gradient, whatever the gradient's size. The step changes the weights by 2.9% of their size. A real run would start this rate near zero (warmup) and end it with a cosine or WSD cooldown. Section 5
  6. 6 · Regularise. Decoupled decay: every weight shrinks by ηλ = 3 × 10−4 of itself, beside the gradient step, as AdamW prescribes; with Adam and L2 in the loss it would have been rescaled per weight (thread 4). Its size, 0.0227, is 1.0% of the update's (the green column against the purple one). No dropout. Section 6
  7. 7 · Measure. On the batch it trained on, the loss fell from 2.60 to 0.22 and accuracy rose from 9.4% to 100.0%; on 256 held-out examples (teal) the loss went from 2.77 to 2.71 and accuracy from 11.3% to 11.7%. One step memorised its batch and learned almost nothing general, which is why loss is measured on held-out data. Section 7
  8. Four threads. The arcs tie moments chosen together: cross entropy is both the loss and the measurement; keeping the variance constant ties initialisation to the forward pass; vanishing gradients run from the forward pass into the backward one; weight decay is a regulariser implemented in the update. Four threads

Bars and columns are the toy's numbers, each station on its own scale (the labels carry the values); dots show what moves at that moment and how many is schematic. One step shows what each moment computes, not which recipe is better: that takes thousands of steps, in the Training lab.

The toy network and the two recipes, sourced

The toy: 16 layers of width 64; a batch of 32 random inputs (64 numbers each, standard normal) labelled into 10 classes by a fixed random linear "teacher"; a held-out batch of 256 from the same teacher. Classic: ReLU, He initialisation, BatchNorm, residual connections, SGD with momentum 0.9 at learning rate 0.1 and weight decay 10−4, as in ResNet (§3.4). 2026: pre-RMSNorm blocks with a SwiGLU feed-forward, AdamW with β = (0.9, 0.95), weight decay 0.1 and gradient clipping at 1.0, as in Llama 2 (§2.2) and DeepSeek-V3; the toy's learning rate (3 × 10−3, with no warmup) is illustrative. Every number is computed in your browser and matches an independent PyTorch run (src/read/recompute.py) to 10−7 or better.

The map: what is chosen at each moment, then and now, and who owns it

Moment, and what is chosenPage that owns it2012 to 20162026 LLM
1 Data, init
batch size, input scaling, the starting weights' scale
Normalisation and initialisationstandardised inputs; He initfan-in or σ = 0.02 init, residual branches scaled down
2 Forward
the nonlinearity; the norm and where it sits
Activation functions; norms on Normalisation and initialisationReLU, BatchNormSwiGLU, pre-RMSNorm
3 Loss
the loss, from the target's type
Loss functionscross entropycross entropy on the next token
4 Backward
what keeps the gradient usable
no single owner: causes on the pages above, clipping on Optimisersresiduals, BatchNorm, no clippingresiduals, norms, clip at 1.0
5 Update
optimiser and schedule, as a pair
Optimisers and learning-rate schedulersSGD + momentum 0.9; step decayAdamW (or Muon); warmup, cosine or WSD
6 Regularise
penalty, dropout, augmentation, stopping
RegularisationL2 10−4 in the gradient, augmentationdecoupled weight decay 0.1, little else
7 Measure
the metric, on held-out data
Evaluation metricsheld-out accuracyheld-out loss (perplexity), benchmarks

Three more pages sit beside the step rather than inside it (Beyond one network): Classical ML, Contrastive and self-supervised learning and Sequence models: the pre-transformer lineage. The recipes come from Defaults across models, which sources every cell for 21 landmark models.

You need gradient descent and the chain rule (Topic: math, sections on the gradient step and the chain rule; Calculus and optimisation for ML has the depth), and for the threads, likelihood and entropy (Probability for ML, Information theory for ML).

New terms on this page (12)

Mini-batch: the few dozen examples (or few million tokens) one gradient is computed on. Loss, cost: one example's error, and its batch mean (used interchangeably). Residual connection: x + F(x), an identity path around a layer. Pre-norm, post-norm: normalising the branch input, x + F(LN(x)), against the sum, LN(x + F(x)). Vanishing, exploding gradient: a product of per-layer factors that shrinks to nothing or grows without bound. Gradient clipping: scale the gradient down when its norm exceeds a threshold. Adaptive optimiser: one step size per parameter. Schedule: how the base learning rate moves over the run; warmup its ramp at the start, cooldown its decay at the end. Decoupled weight decay: shrinking the weights in the update, not through the loss. Held-out set: data the model never trains on, kept to measure it. Chance loss: what a model that knows nothing scores, ln K for K classes.

Numbers are published, with the source linked, unless marked derived (formula shown), illustrative, reported (the maker's own figure, not independently checked) or unconfirmed.

1 · Data and initialisation: what the step starts from

The batch is a compromise: the whole training set gives an exact but slow step (batch gradient descent), one example a cheap but very noisy one (stochastic gradient descent in the strict sense), and a mini-batch is efficient on hardware and only mildly noisy. Inputs are put on a common scale first (standardised, z = (x − μ)/σ, or min-max to [0, 1]) so no feature dominates because of its units.

The starting weights are random, never constant (equal weights get equal gradients and stay copies of each other), and their scale is the whole game: a layer with n inputs multiplies the signal's variance by about n · Var(w) times a factor set by its activation, so Var(w) is chosen to make that product 1. Xavier's 2/(nin + nout) suits sigmoid and tanh, He's 2/nin the ReLU family, LeCun's 1/nin SELU; large LLMs use a small fixed scale (OLMo 2 σ = 0.02, DeepSeek-V3 0.006) and scale residual branches down by 1/√N (GPT-2). Because the right scheme depends on the activation, init is chosen with it: thread 2.

Go deeper: scaling and every scheme, with the variance derivation, on Normalisation and initialisation (sections 1, 2 and 6; its Fig. 1 measures one batch through 20 layers); batch size and the learning rate on Optimisers and learning-rate schedulers (section 6); imbalanced classes in When training goes wrong.
Fig. 2 · one batch through five 16-layer networks: spread on the way up, gradient on the way down

2 · Forward: activations and normalisation

Each layer is a linear map and a nonlinearity (without it the stack collapses to one linear map), and in every modern network also a normalisation and a residual connection. The activation rule is short: the ReLU family in hidden layers, the gated SwiGLU in transformer feed-forward blocks (a third matrix, so the hidden width is cut to ⅔ · 4d), and at the output whatever the target needs: a sigmoid per output for binary or multilabel, softmax for classes, nothing for regression. The norms differ by axis: BatchNorm normalises each feature across the batch (CNNs; it needs running averages at inference), LayerNorm and RMSNorm each example across its features (transformers; RMSNorm drops the mean and is in essentially every current LLM). Where the norm sits, before the branch (pre-norm, GPT-2 onwards) or after the sum (post-norm, 2017), is Normalisation, residuals and stability's subject.

Watch the variance, layer by layer

Fig. 2: the same batch goes through five 16-layer networks, each a different pairing of activation, initialisation and normalisation, forward (top: how spread out each layer's output is) and backward (bottom: the size of each layer's weight gradient). Both axes are logarithmic: one gridline is a factor of 10. Predict: which network's first layer gets the smallest gradient? Pick a network above the chart; the grey dots are the one chosen under "compare with".

  1. The batch. 32 inputs of 64 numbers, spread (standard deviation) 1.02: the grey bar on the left of the top panel.
  2. Forward, layer by layer. Each blue bar is how spread out a layer's 32 × 64 outputs are. On this log scale, a steady staircase down or up means the same factor lost or gained at every layer.
  3. The loss. Cross entropy over 10 classes; a network that cannot tell its inputs apart scores ln 10 = 2.303. Now the gradient flows back down.
  4. Backward, layer 16 down to layer 1. Each layer's gradient (bottom panel) is the one above it times the layer's own Jacobian: a product that grows by one factor per layer, so a factor below 1 vanishes and one above 1 explodes.
  5. First layer against last. The ratio of the first layer's gradient to the last's says how much the path down shrank or grew it; the note under the chart reads it for the chosen network.

Width 64, batch 32, 16 layers, 10 classes, at initialisation. Activation spread: the standard deviation of every number a layer outputs (for residual networks, the residual stream). Gradient: the Frobenius norm of ∂loss/∂W for the layer's weights (for SwiGLU blocks, of all three matrices together). The "ReLU, init too small" network uses LeCun's 1/n with ReLU, half of He's variance, so its signal loses half its second moment at every layer. Inputs and weights are seeded and illustrative; the per-layer numbers are exact and match PyTorch autograd to 10−8 (src/read/recompute.py).

Go deeper: every activation, dead units measured and the 2/3 rule on Activation functions (its Fig. 3 runs one token through two feed-forward blocks); BatchNorm, LayerNorm and RMSNorm as one recipe on different axes on Normalisation and initialisation (sections 3 to 5; its Fig. 5, one tensor and five choices of axes); placement, QK-norm and loss spikes on Normalisation, residuals and stability.

3 · Loss: one number to descend

The loss follows from the target. A number gets a regression loss: MSE by default (it estimates the mean), MAE (the median) or Huber when outliers are real. A class gets cross entropy, minus the log of the probability given to the right class, so minimising it is maximum likelihood; label smoothing, class weights and focal loss only reweight its terms, and the hinge loss is the margin-based outsider (the SVM's). An order gets a ranking loss, a distribution KL divergence (VAEs, distillation, the RLHF anchor), and a GAN an adversarial game. L1 and L2 penalties are added to the loss but belong to regularisation.

Fig. 3: slide the probability the model gives the right class (10 classes, the rest shared equally) and compare what each loss charges and how hard it pushes. The gradient is with respect to the right class's logit: the size of the push. Predict: where does label smoothing's loss bottom out?

Check where the loss starts. A K-class classifier that knows nothing should score ln K: ln 10 = 2.303 for the toy. Its pre-norm network starts at 2.60 and the "init too small" one at 2.3025, but the BatchNorm residual network starts at 5.42, because its residual stream grows to a standard deviation of 2.47 by the last layer and nothing normalises it before the output (Fig. 2 shows the growth). A starting loss far from ln K is the first thing to check in When training goes wrong.

Go deeper: regression losses as noise models, cross entropy's gradient p − y (section "Cross entropy: likelihood, KL, and the gradient p − y", with Fig. 3, one real next-token prediction), the family, margins, ranking and the adversarial loss on Loss functions; swap the loss in a network that trains live in the Training lab.
Fig. 3 · what three classification losses charge, and how hard they push
cross entropylabel smoothing, ε = 0.1focal

Exact formulas; the gradients match PyTorch autograd. Label smoothing uses Szegedy et al.'s target, 1 − ε + ε/K on the right class and ε/K on each other, so its loss is lowest at p = 0.91, not at 1; some texts put 1 − ε on the right class and ε/(K − 1) on the others, which moves that minimum to 0.9. Focal loss, −(1 − p)γ log p, down-weights the easy examples (Lin et al. 2017).

4 · Backward: where gradients vanish or explode

Backpropagation applies the chain rule from the loss back to every weight, so a weight in layer 1 of 16 receives a product of 15 layer factors: below 1 the product vanishes, above 1 it explodes, the same arithmetic in a deep stack and in a recurrent network unrolled through time (thread 3). The bottom panel of Fig. 2 is this step: in the sigmoid network the first layer's gradient is 9.5 × 10−11 against 0.18 for the last, about 2 billion times smaller derived (each sigmoid layer multiplies by its slope, at most 0.25); in the pre-norm SwiGLU network the ratio is 1.45 to 1.17, because the residual path carries the gradient down untouched.

The causes live on four different pages, which is why this table belongs here:

CauseFix, by the stage it belongs to
Saturating activationsReLU family or smooth ReLUs (step 2, Activation functions)
Wrong initial scaleXavier for sigmoid and tanh, He for ReLU (step 1, Normalisation and initialisation)
Depth itselfresidual connections (an identity path for the gradient) and normalisation layers (step 2); or fewer layers
Recurrence through timethe LSTM's additive cell state, a skip connection through time (Sequence models: the pre-transformer lineage)
A rare huge gradientgradient clipping: if the gradient's norm exceeds a threshold, scale it down to the threshold (Pascanu et al. 2013); LLM runs typically clip at 1.0, as Llama 2 and DeepSeek-V3 do

In Fig. 1 (step 4), the 2026 recipe's gradient norm is 5.50 and clipping scales it to 1.0 before the update, while the classic recipe (no clipping) passes its 13.4 straight on. How a vanishing or exploding gradient shows in a loss curve is in When training goes wrong.

5 · Update: optimisers and schedules

The update turns a gradient into a weight change through three choices made together: smoothing over steps (momentum), a step size per parameter (adaptive methods), and the base rate's path over the run (the schedule). Adaptive methods only rescale relative to the base rate, so an optimiser and a schedule are always chosen as a pair. The families, by what they change:

FamilyWhat it changesWhere it is the defaultOwner's section
SGD + momentum (Nesterov)direction smoothed over steps; one step size for allvision, ResNet-style training1
Adam, AdamWper-parameter steps from a running RMS of the gradient, bias-corrected; AdamW decouples the weight decayessentially every LLM2
Shampoo, SOAPfull-matrix (Kronecker-factored) preconditioningAlgoPerf winners; little LLM use3
Muon, Lionthe update's shape: Muon orthogonalises each hidden matrix's momentum (Newton-Schulz), Lion takes its signMuon pretrains Kimi K2 (1T parameters, as MuonClip)4
Schedule-free, WSMremove the decay curve: iterate averaging, or merging checkpointsruns whose length is not known8

Schedules differ on one question: does the schedule need the run's length in advance? Warmup then cosine to about 10% of the peak needs it, so a cosine run stopped early sits at an untuned rate; WSD (warmup, stable, decay) holds the rate flat and decays over the last 10 to 20%, so the end can be chosen late. At a fixed, known budget the shapes nearly tie. Warmup exists because Adam's second-moment estimate rests on a handful of gradients in the first steps.

Go deeper: on Optimisers and learning-rate schedulers: momentum on a ravine (Fig. 1, three optimisers on one ravine), Adam and AdamW with bias correction animated (section 2), Muon's five Newton-Schulz iterations on this page's own 64 × 176 gradient (section 4, Fig. 4), the evidence when the baseline is tuned (5), batch size and the learning rate (6), schedules and why cosine must know the end (7, Fig. 6, three endpoints) and schedule-free and WSM (8); the optimiser race in its Optimiser race tab; swap optimisers and schedules live in the Training lab; what landmark models used in Defaults across models.

6 · Regularise: fit the pattern, not the batch

Regularisation trades a little training fit for better performance on unseen data. Each kind acts at a different moment of the step:

KindActs atHow
Penaltythe loss (step 3) or the update (step 5)L1 (lasso) zeroes some weights, L2 (ridge) shrinks all, elastic net adds both
Dropoutthe forward pass (step 2)drop each unit with probability p in training, so no unit relies on one partner; survivors are rescaled in training, so inference drops nothing
Augmentationthe data (step 1)random but realistic transforms enlarge the training set
Early stoppingthe measurement (step 7)stop when validation loss turns up; keep the best checkpoint

LLM pretraining uses almost none of this: it sees most data about once, so there is little to overfit. What remains is weight decay, a regulariser by intent and an optimiser property by implementation (thread 4): in Fig. 1 the classic recipe folds 10−4·w into the gradient, while the 2026 recipe shrinks every weight by ηλ = 3 × 10−4 of itself, separately.

Go deeper: on Regularisation: penalties and their geometry (section 2, Fig. 2, two coefficients and one penalty at a time), weight decay and why AdamW decouples it (3, Fig. 3), dropout as an ensemble of thinned networks (4, Fig. 4), augmentation (5), what each buys, measured (7), and what large-model training still uses (9); overfitting against underfitting in When training goes wrong.

7 · Measure: on data the step did not see

The toy's single step shows why measuring needs held-out data: under the 2026 recipe, the loss on the batch it trained on fell from 2.60 to 0.22 and accuracy on that batch went from 9.4% to 100%, while on the 256 held-out examples the loss moved from 2.77 to 2.71 and accuracy from 11.3% to 11.7%. One step memorised its batch and learned almost nothing general.

What to measure falls into three families. Classification numbers come from the confusion matrix at a threshold (precision, recall, F1) or across all thresholds (ROC-AUC, precision-recall); when positives are rare, ROC barely moves while precision-recall collapses, because the false positive rate divides by the whole negative class. Text scores compare an output with a reference (BLEU on clipped n-gram precision, ROUGE on recall, METEOR with stems and synonyms, BERTScore on embeddings), and perplexity, exp(mean negative log-likelihood per token), is the loss itself read as a measurement, comparable only under the same tokenizer. Information quantities (entropy, cross entropy, KL) are thread 1. Judging LLM output has moved to LLM judges and task benchmarks (Topic: evaluation-and-llm-judges).

Go deeper: on Evaluation metrics: the threshold and the accuracy trap (section 1, Fig. 1, one threshold and four counts), ROC against precision-recall as positives get rarer (2), calibration (3), regression (5), ranked lists (6), text metrics (7), perplexity and the tokenizer (8, Fig. 3, one text and three tokenizers), and error bars (10).

Four threads that cross the stages

Followed one stage at a time, the components look like separate menus. Four threads run through several stages at once, and they are the reason the choices come in matched sets.

1 · Everything is cross entropy

Entropy H(P) = −Σ P log P is the average cost of encoding samples from P with P's own best code; cross entropy H(P, Q) = −Σ P log Q is the cost with a code built for Q; their difference is the KL divergence, DKL(P‖Q) = H(P, Q) − H(P) = Σ P log(P/Q), the extra paid for using the wrong code. KL is asymmetric and breaks the triangle inequality, so it is distance-like, not a distance. Since H(P) does not depend on the model, minimising cross entropy and minimising KL are the same thing, and that one fact runs through four stages:

  • The loss (step 3): with a one-hot label H(P) = 0, so cross entropy = KL = the negative log-likelihood of the right class. Label smoothing and distillation make P soft, so H(P) > 0 sets a floor the loss cannot go below; distillation's choice of forward or reverse KL decides where a small student is allowed to be wrong (Distillation and Small Language Models).
  • The anchor: the same KL keeps a VAE's latent code near its prior and an RLHF policy near its reference model (Topic: llm-training-and-post-training, Axis 4).
  • Contrastive learning: InfoNCE is cross entropy over a batch, a classification of the one matching pair among N candidates (below).
  • The measurement (step 7): perplexity is exp(cross entropy) per token, and a log-loss on held-out data is the same number the step minimised, now read as a score.

Fig. 4: pick a target, then slide how much probability the model puts on the right answer. The bar is cross entropy split into the part no model can remove (H(P)) and the part training removes (KL).

Fig. 4 · cross entropy = what no model can remove + what training removes

2 · Keep the variance constant: the pact between initialisation, activation and normalisation

Initialisation (step 1) and normalisation (step 2) chase one invariant: activation and gradient variance roughly constant from layer to layer, at step zero and for the rest of training. Initialisation sets it for step zero, and only for the activation it was derived for; normalisation re-imposes it at every step, which is why deep normalised networks are far less sensitive to the initial scale. So the three are chosen as a set:

ActivationInitialisation that keeps the varianceNormalisation it is usually paired with
Sigmoid, tanhXavier, 2/(nin + nout)none (pre-2015 networks), or the LSTM's own gates
ReLU familyHe, 2/ninBatchNorm in CNNs
SELULeCun, 1/ninnone: the activation itself pulls activations towards mean 0, variance 1
GELU, SwiGLU in transformerssmall fixed or fan-in scale, residual outputs scaled downLayerNorm, now RMSNorm, before each block; QK-norm in attention

Load the matching pairs into Fig. 2 and compare:

3 · Vanishing gradients, seen four ways

One failure shows up in four stages, and each stage has its own fix. In every case the gradient reaching an early layer is a product of per-layer (or per-time-step) factors:

  1. Activation saturation (step 2): a sigmoid's slope is at most 0.25, so each layer shrinks the gradient by at least 4. The fix is the ReLU family.
  2. Initialisation scale (step 1): a variance below the activation's balance point shrinks the signal at every layer, above it grows it. The fix is the matching scheme.
  3. Normalisation and placement (step 2): with the norm after the residual sum, every layer rescales the path the gradient travels; with it before the branch, the residual stream is an identity path.
  4. The product of Jacobians through time (backpropagation through time): a recurrent network applies the same weights at every step, so the gradient from step T back to step T − k multiplies k copies of the same factor. The LSTM's fix is its cell state, updated by addition, Ct = ft ⊙ Ct−1 + it ⊙ C̃t: along it the gradient is multiplied only by the forget gate, which the network can hold near 1. It is a skip connection through time.

Fig. 5: the fourth way, on one 60-step input sequence. Move the recurrent weight: the tanh network's gradient vanishes for every value, small weights shrinking it directly and large ones saturating the tanh, whose slope then shrinks it. The LSTM's cell path keeps its gradient alive while the forget gate stays near 1; lower its bias and it vanishes too.

All four are why "fix vanishing gradients" never has one answer, and why a symptom in the loss curve has to be traced back through every stage (When training goes wrong).

Fig. 5 · one 60-step sequence: the gradient k steps back, tanh RNN against the LSTM cell
tanh RNN, gradient on its state k steps backLSTM, gradient along the cell state

A scalar tanh RNN, at = tanh(w at−1 + xt), whose factor per step is w(1 − at2); and an LSTM cell path whose factor is the forget gate ft = σ(bf + xt), on the same seeded inputs xt ~ N(0, 0.52) illustrative; the products are exact. Exploding gradients need the factor to stay above 1, which a saturating unit resists; they appear in larger networks and are handled by clipping (step 4). Initialising the forget bias to 1 or more is a standard recommendation (Jozefowicz et al. 2015).

4 · Weight decay: a regulariser by intent, an optimiser property by implementation

Weight decay is meant as a regulariser (step 6) but is implemented in the update (step 5), two ways. As L2 in the loss, λ/2 · ‖w‖2 adds λw to the gradient; as decoupled decay, w ← w − ηλw beside the gradient step. For plain SGD they are identical. For Adam they are not: the L2 term is divided by √v̂ like every gradient component, so weights with large, noisy gradients are barely decayed and weights with tiny gradients are pulled to zero at full speed. Decoupling restores one decay for every weight, and that is the whole of AdamW (Loshchilov and Hutter 2017).

See it: in Regularisation's Fig. 3 (section 3), six weights get pure noise as their gradient and Fig. 3 runs both optimisers on the same noise: Adam with L2 decays the quiet weights and barely touches the noisy ones, AdamW decays all six alike; the shrink per step against gradient noise is drawn in section 2 of Optimisers and learning-rate schedulers.

Beyond one network

The step above is supervised deep learning. Three neighbouring paradigms reuse its parts and add one idea each.

ParadigmThe one idea it addsWhat it shares with the stepOwner
Classical MLmodels that are not trained by backpropagation: trees and ensembles, kernels, neighbours, clusterslosses (MSE, log-loss, hinge), L1 and L2, the metricsClassical ML
Contrastive and self-supervisedlabels made from the data itself: pairs, masks, predicted representationsInfoNCE is cross entropy (thread 1); augmentation becomes the taskContrastive and self-supervised learning
Sequence models before the transformerone state carried through timevanishing gradients through time (thread 3); gating, the ancestor of SwiGLUSequence models: the pre-transformer lineage

Classical ML: still the default on tables

Bagging (random forests) cuts variance, boosting (each tree fits the loss's gradient) cuts bias, and gradient-boosted trees (XGBoost, LightGBM, CatBoost) were long the strong default on tabular data, generally ahead of deep networks there (Grinsztajn et al. 2022). Tabular foundation models now report beating tuned boosted trees on small datasets reported (TabPFN v2, Nature 2025); on the TabArena leaderboard (2 October 2026) they hold the top places, while at 100k to 1M rows tuned boosted trees and RealMLP sit within overlapping intervals. For tuning any model, random search beats grid search at equal budget (Bergstra and Bengio 2012). The dated evidence (section 4) and every method (sections 1 to 10) are on Classical ML.

Contrastive and self-supervised learning: the objective makes the embedding model

InfoNCE classifies the one matching pair among the N items of a batch, so a model that knows nothing scores ln N: ln 32,768 = 10.4 for CLIP's batch derived (CLIP). Because the batch is the set of negatives, its size changes the task itself, which is why MoCo built a queue. The architecture follows the objective: a contrastive loss wants one vector per input, so it produces encoders, and in 2026 contrastive training is the standard recipe that turns any backbone, increasingly a decoder-only LLM, into an embedding model. Margins and triplets, the six designs, collapse and its defences, MAE and JEPA are on Contrastive and self-supervised learning.

Sequence models before the transformer: what the transformer kept

The pre-transformer lineage earns its place because the transformer is what is left of it.

YearModelIdea, and what survived
1980sRNNat = f(Uxt + Wat−1), weights shared across time, trained by backpropagation through time; long-range gradients vanish or explode (thread 3)
1997LSTM (Hochreiter and Schmidhuber)sigmoid input and output gates around an additively updated cell state (the forget gate came in 2000, Gers et al.): a skip connection through time; its gating is the ancestor of SwiGLU
2013, 2014word2vec (Mikolov et al.), GloVe (Pennington et al.)one static vector per word, predicted from context (skip-gram, CBOW, negative sampling) or fitted to log co-occurrence counts; king − man + woman ≈ queen; superseded by contextual embeddings (ELMo, BERT)
2014GRU (Cho et al.)two gates, cell and hidden state merged, ht = (1 − zt) ⊙ ht−1 + zt ⊙ h̃t: the same additive trick with about a quarter fewer parameters
2014seq2seq (Sutskever et al.)an encoder RNN squeezes the source into one vector for a decoder RNN; quality collapses on long inputs (the bottleneck)
2014, 2015attention (Bahdanau et al., Luong et al.)keep every encoder state; at each output step, score them against the decoder state, softmax, take the weighted sum: the bottleneck disappears
2016WaveNet (van den Oord et al.)dilated causal convolutions, a receptive field growing exponentially with depth and no recurrence; its gated unit tanh ⊙ σ prefigures the GLU family
2017Transformerdrops recurrence and keeps only attention, fully parallel over the sequence (Attention Is All You Need); everything after it is Topic: llm-architecture, Topic: llm-landscape and Topic: llm-training-and-post-training
2023 to 2026state-space modelsrecurrence partly returns: Mamba and hybrid SSM-attention stacks get RNN-like constant cost per generated token with parallel training (Mamba)
Go deeper: the LSTM gate by gate on trained weights (Fig. 3, one cell of the trained LSTM), GRU, seq2seq with attention, WaveNet and real GloVe vectors (its Word vectors tab) on Sequence models: the pre-transformer lineage.

When it goes wrong

Every training failure lands on one of the seven stages, so debugging reads as the step run backwards from the symptom: a loss flat from the start points at the update or the backward pass (a rate off by 10, frozen layers, a loss that does not match the output activation), a loss that turns to not-a-number at numerics in the loss, oscillation at the learning rate or batch size, a plateau at vanishing gradients or dead ReLUs, training loss falling while validation loss rises at regularisation, good accuracy that is useless on the minority class at the metric. The symptom-to-cause-to-fix tables and the standing checklist are in When training goes wrong; the Training lab lets you cause each failure on purpose.

The nine pages under this one

In the order of the step; reading times as each page's header states them.

Feature scaling, initialisation schemes (Xavier, He, LeCun, orthogonal, μP), and BatchNorm, LayerNorm, RMSNorm, GroupNorm and weight standardisation as one recipe on different axes. Steps 1 and 2, thread 2. Figures: Fig. 1, one batch through 20 layers, Fig. 3, one loss, three units, Fig. 5, one tensor, five choices of axes. (24 min, plus 14 in closed details)

Saturation, the ReLU family and dead units measured, smooth rectifiers, the gated units and the 2/3 rule, what real models use, the output layer. Step 2. Figures: Fig. 1, folding the plane with two ReLUs, Fig. 2, 384 hidden units, measured, Fig. 3, one token through two feed-forward blocks. (27 min, plus 5 in closed details)

What a loss makes a model estimate: regression losses as noise models, cross entropy and its gradient, focal loss and label smoothing, margins, ranking losses, the adversarial loss. Step 3. Figures: Fig. 1, a real padded batch, Fig. 2, one bad target, three losses, Fig. 3, one real next-token prediction, Fig. 4, every logit shifted together. (32 min, plus 5 in closed details)

Momentum, Adam and AdamW, Shampoo and SOAP, Muon and Lion, the evidence under a tuned baseline, batch size and the learning rate, schedules, schedule-free and WSM; an optimiser race. Step 5. Figures: Fig. 1, three optimisers on one ravine, Fig. 2, per-coordinate steps, Fig. 3, optimiser state beside one expert matrix, Fig. 4, Newton-Schulz on one real gradient, Fig. 5, the noise floor, Fig. 6, three endpoints. (33 min, plus 14 in closed details)

Penalties and their geometry, weight decay and AdamW, dropout, augmentation and mixing, early stopping, what each buys, and regularisation in networks that can memorise. Step 6, thread 4. Figures: Fig. 2, L1 and L2 on two coefficients, Fig. 3, weight decay on pure noise, Fig. 4, one digit through dropout. (32 min, plus 8 in closed details)

Thresholds, ROC and precision-recall, calibration, multi-class averaging, regression and ranked-list metrics, text metrics, perplexity, error bars, on real model outputs. Step 7. Figures: Fig. 1, one threshold, four counts, Fig. 2, one query, ten results, Fig. 3, one text, three tokenizers. (29 min, plus 7 in closed details)

Linear models, trees and ensembles, the dated tabular evidence, SVMs, kNN, clustering, anomaly detection, PCA and t-SNE, hyperparameter search; a boundary lab. Figures: Fig. 1, a tree grown depth by depth, Fig. 2, one tree, a forest and boosting, Fig. 3, the SVM score as a height, Fig. 4, PCA on three measurements. (31 min, plus 8 in closed details)

Margin and triplet losses, InfoNCE, six designs (SimCLR to VICReg), alignment and uniformity, collapse, MAE and JEPA, CLIP and embedding models. Figures: Fig. 1, eight sentence pairs, Fig. 2, one anchor, 48 candidates, Fig. 3, two branches, six designs, Fig. 4, digits on the unit sphere. (32 min, plus 8 in closed details)

Recurrence, the gradient through time, the LSTM gate by gate, GRU, seq2seq and attention, WaveNet, why the transformer replaced them, static word vectors. Thread 3. Figures: Fig. 2, a trained RNN, unrolled, Fig. 3, one LSTM cell, Fig. 4, two encoder-decoders, Fig. 5, one output traced back. (24 min, plus 5 in closed details)

Built from the old page "Topic: ml-fundamentals" (last edited 22 September 2026, fetched 3 October 2026) and its ten child pages, with every figure rechecked against its source on 3 October 2026; the page "Debugging training" is folded into this page. Rebuilt on 24 October 2026 as a map once its nine children were rebuilt. Toy computations: src/read/recompute.py (PyTorch and NumPy) and src/read/check_engine.mjs.