Applied MLby ArxFoundry
Glossary

Glossary

Every concept in the book, with where it's explained. Greyed entries aren't written yet. The PyTorch and scikit-learn sections double as an index of where each part of those libraries is taught.

Maths

accumulation function
The area under a curve from a fixed start up to x, treated as a function of x. It is a running total: for a speed curve, it is the odometer.
1. Maths toolkit · Adding up the continuous: integrals
area under the curve
The region between a curve and the horizontal axis over a range. Its size is the integral. Parts below the axis count as negative.
1. Maths toolkit · Adding up the continuous: integrals
argmax
The position (input) where a list or function is biggest, as opposed to max, which is the biggest value itself. argmax of (2, 1, 0, −1) is position 0.
1. Maths toolkit · Scores to probabilities: argmax, softmax and log-probabilities
basis vectors
The arrows (1, 0) and (0, 1) in 2D: one step along each axis. Every vector is a mix of them, and a matrix's columns are where they land.
1. Maths toolkit · Matrices as transformations: determinants and inverses
chain rule
The slope of a chain of functions is the product of each link's slope, each taken at the value flowing through it: d f(g(x))/dx = f′(g(x)) · g′(x).
1. Maths toolkit · Chains of functions: the chain rule
composition
Doing one transformation and then another. The combined matrix is their product, read right to left: AB means do B first, then A. Order matters.
1. Maths toolkit · Matrices as transformations: determinants and inverses
composition
Feeding one function's output into another: (f ∘ g)(x) = f(g(x)). Do g first, then f.
1. Maths toolkit · Chains of functions: the chain rule
computational graph
A formula broken into small steps (add, multiply, square, …), drawn as boxes joined by arrows. Values flow forward through it; gradients flow backward, multiplied by each step's local slope.
1. Maths toolkit · Chains of functions: the chain rule
contour plot
A map of a function of two inputs. Each contour line joins the points with the same output, like height lines on a hiking map.
1. Maths toolkit · Many knobs: partial derivatives and the gradient
convex
A curve is convex if every chord (straight line between two points on it) lies on or above the curve. Equivalently, its curvature is never negative. A convex curve has no separate valleys, so gradient descent can't get stuck in the wrong one.
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
cosine similarity
The dot product divided by both vectors' lengths. It compares direction only: 1 means same direction, 0 means at right angles (no shared direction), -1 means opposite.
1. Maths toolkit · Vectors: lists of numbers
curvature
How sharply a curve bends at a point, measured here by the second derivative. Positive means it bends up like a bowl, negative means it bends down like a hill top, and a bigger size means a sharper bend.
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
derivative
The slope of a curve at one point: the slope of the tangent line, found by letting the nudge h in (f(x + h) − f(x)) / h shrink towards zero. Written f′(x) or df/dx.
1. Maths toolkit · How things change: derivatives
derivative rules
A short table of slopes: constant → 0, xⁿ → n xⁿ⁻¹, eˣ → eˣ, log x → 1/x; constant multiples and sums carry through.
1. Maths toolkit · How things change: derivatives
determinant
For a square matrix, the number that says how much it scales area (or volume in 3D). Its sign says whether space gets flipped. Zero means space is squashed flat. For a 2×2 matrix it is ad − bc.
1. Maths toolkit · Matrices as transformations: determinants and inverses
directional derivative
The slope of a function when you move in a chosen direction u (a unit vector). It equals the dot product ∇f · u.
1. Maths toolkit · Many knobs: partial derivatives and the gradient
dot product
Multiply matching entries of two vectors and add the results. The answer is a single number that is large when the vectors point the same way, zero at right angles, and negative when they point apart.
1. Maths toolkit · Vectors: lists of numbers
eigenvalue
The number λ an eigenvector gets multiplied by: A v = λ v. Bigger than 1 stretches, between 0 and 1 shrinks, negative flips.
1. Maths toolkit · Directions that only stretch: eigenvectors and eigenvalues
eigenvector
A non-zero vector that a matrix only stretches (or flips), without turning it off its line: A v = λ v. Any multiple of it works too, so it's really a direction.
1. Maths toolkit · Directions that only stretch: eigenvectors and eigenvalues
exponential function
The exponential function exp(x) = eˣ, where e ≈ 2.718. Always positive; adding 1 to x multiplies the output by e. Its slope at every point equals its height.
1. Maths toolkit · Warm-up: functions and graphs
function
A rule that turns each input into exactly one output, like distance in, delivery time out. Written f(x): the output of f for the input x.
1. Maths toolkit · Warm-up: functions and graphs
fundamental theorem of calculus
The rate of change of the accumulated area under a curve equals the curve's height: d/dx of ∫ₐˣ f(t) dt is f(x). So integrating and differentiating undo each other.
1. Maths toolkit · Adding up the continuous: integrals
geometric series
A sum where each term is the last one times the same ratio r: 1 + r + r² + … = 1/(1 − r) when |r| < 1.
Not written yet · 5. Reinforcement learning · Returns and discounting
gradient
The vector of all partial derivatives of a function, written ∇f. As an arrow it points in the steepest uphill direction, at right angles to the contour lines, and its length is the steepest slope.
1. Maths toolkit · Many knobs: partial derivatives and the gradient
graph
The picture of a function: one point (x, f(x)) for every input x. Read it by going up from an input on the x-axis to the curve, then across to the y-axis.
1. Maths toolkit · Warm-up: functions and graphs
Hessian
The table of all second derivatives of a function of several inputs: row i, column j says how the slope in input i changes as input j moves. It is symmetric, and its eigenvalues are the curvatures along the main directions.
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
identity matrix
The matrix with 1s on the diagonal and 0s elsewhere, written I. It moves nothing: I v = v for every vector v. It plays the role of the number 1.
1. Maths toolkit · Matrices as transformations: determinants and inverses
integral
The exact total you get by adding up a curve's values over a range in thinner and thinner slices. Written ∫ f(x) dx from a to b. As a picture, it is the area under the curve between a and b.
1. Maths toolkit · Adding up the continuous: integrals
inverse
The matrix A⁻¹ that undoes A: doing A and then A⁻¹ (or the other way round) leaves everything where it started, so A⁻¹A = I. It exists only when det A is not zero.
1. Maths toolkit · Matrices as transformations: determinants and inverses
Jacobian
The matrix of all partial derivatives of a vector-valued function: row i, column j holds ∂(output i)/∂(input j). Chaining functions multiplies their Jacobians.
1. Maths toolkit · Chains of functions: the chain rule
length
How long a vector's arrow is: the square root of the sum of its squared entries (Pythagoras). Written ‖x‖. Also called the norm.
1. Maths toolkit · Vectors: lists of numbers
linear approximation
Near a point a, replace the curve with its tangent line: f(a + h) ≈ f(a) + f′(a)·h. Good for small moves h; the error grows like h².
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
linear function
A function whose graph is a straight line: f(x) = wx + b. The slope w is the change in output per 1 step of input; the intercept b is the output at x = 0.
1. Maths toolkit · Warm-up: functions and graphs
linear system
A set of equations where unknowns are multiplied by numbers and added, written A x = b. Solving it means finding the input x that the matrix A sends to b.
1. Maths toolkit · Matrices as transformations: determinants and inverses
linear transformation
A way of moving every point of space that keeps grid lines straight, parallel and evenly spaced, and keeps the origin fixed. Every matrix is one, and every one is a matrix.
1. Maths toolkit · Matrices as transformations: determinants and inverses
local minimum
A point lower than all points near it: the bottom of a valley. The slope there is zero and the curve bends up. It need not be the lowest point overall (the global minimum).
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
log
The undo of the exponential: log_b y is the power p that makes b^p = y, so log₂ 8 = 3. Plain log means base e (ln). Turns products into sums.
1. Maths toolkit · Warm-up: functions and graphs
logsumexp
log Σ exp(zⱼ): exponentiate each score, add them up, take the log. A smooth version of max. Computed safely by pulling out the biggest score first. log softmax(z) = z − logsumexp(z).
1. Maths toolkit · Scores to probabilities: argmax, softmax and log-probabilities
matrix
A table of numbers with rows and columns. In ML, each row is usually one example and each column one feature. Multiplying a matrix by a vector does one dot product per row.
1. Maths toolkit · Matrices: tables of numbers
Matrix multiplication
A B: entry (i, j) is the dot product of row i of A with column j of B. Needs A's column count to equal B's row count: (n × p)(p × m) gives (n × m).
1. Maths toolkit · Matrices: tables of numbers
matrix power
A matrix multiplied by itself k times, written A^k. Applying A^k is the same as applying A, k times in a row.
1. Maths toolkit · Directions that only stretch: eigenvectors and eigenvalues
matrix-vector product
X w: take the dot product of each row of X with w. The answer is a vector with one entry per row. It is also a weighted sum of X's columns, with weights from w.
1. Maths toolkit · Matrices: tables of numbers
nonlinear function
Any function whose graph is not a straight line, like x² or eˣ. Its slope changes from place to place.
1. Maths toolkit · Warm-up: functions and graphs
numerical integration
Estimating an integral from the curve's values at sample points, for example by adding up rectangles or trapezoids. Used when there is no formula, or no antiderivative.
1. Maths toolkit · Adding up the continuous: integrals
partial derivative
The slope of a function of several inputs when you change one input and hold the others fixed. Written ∂f/∂x.
1. Maths toolkit · Many knobs: partial derivatives and the gradient
power iteration
Find a matrix's biggest-stretch eigenvector by applying the matrix to an arrow again and again, rescaling to length 1 each time. The arrow swings onto that direction.
1. Maths toolkit · Directions that only stretch: eigenvectors and eigenvalues
quadratic approximation
Near a point a, replace the curve with its tangent parabola: f(a + h) ≈ f(a) + f′(a)·h + ½ f″(a)·h². It matches the height, slope and curvature at a.
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
Riemann sum
An estimate of the area under a curve: cut the range into thin slices, make each one a rectangle as tall as the curve somewhere in that slice, and add up the rectangles' areas.
1. Maths toolkit · Adding up the continuous: integrals
Scalar multiplication
Multiply every entry of a vector by the same number. The arrow stretches, shrinks, or flips if the number is negative.
1. Maths toolkit · Vectors: lists of numbers
second derivative
The derivative of the derivative, written f″(x). It measures how fast the slope changes, so it tells you whether the curve bends up (positive) or down (negative).
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
shape
How many rows and columns a matrix has.
1. Maths toolkit · Matrices: tables of numbers
singular matrix
A square matrix with determinant 0. It squashes space into fewer dimensions, so different inputs share an output and there is no inverse.
1. Maths toolkit · Matrices as transformations: determinants and inverses
slope
How steep a straight line is: rise over run. A slope of −76 means the line drops 76 units for every 1 unit you move right.
1. Maths toolkit · How things change: derivatives
spectral radius
The largest size |λ| among a matrix's eigenvalues. If it's below 1, applying the matrix again and again shrinks every vector to zero; above 1, most vectors blow up.
1. Maths toolkit · Directions that only stretch: eigenvectors and eigenvalues
sum notation
The symbol Σ means add up. Σ with i from 1 to n means: work out the expression for i = 1, 2, …, n, then add the results.
1. Maths toolkit · Vectors: lists of numbers
symmetric matrix
A square matrix equal to its own transpose: the entry in row i, column j equals the one in row j, column i. Its eigenvalues are real and its eigenvectors are at right angles.
1. Maths toolkit · Directions that only stretch: eigenvectors and eigenvalues
Taylor series
A curve written as an endless polynomial around a point a: f(a) + f′(a)h + f″(a)h²/2! + f‴(a)h³/3! + … Each term matches one more derivative. Stopping early gives a Taylor approximation.
1. Maths toolkit · Zooming in: linear and quadratic approximation (Taylor)
transpose
Flip a matrix across its diagonal so rows become columns. Written Xᵀ; entry (i, j) of Xᵀ is entry (j, i) of X. A (3 × 2) matrix becomes (2 × 3).
1. Maths toolkit · Matrices: tables of numbers
unit vector
A vector of length 1. Divide any non-zero vector by its length to get the unit vector pointing the same way.
1. Maths toolkit · Vectors: lists of numbers
vector
An ordered list of numbers. In 2D or 3D you can draw it as an arrow from (0, 0) to that point.
1. Maths toolkit · Vectors: lists of numbers
Vector addition
Add two vectors of the same length by adding matching entries. As arrows: put the second arrow's tail on the first arrow's tip.
1. Maths toolkit · Vectors: lists of numbers
weighted sum
Multiply each value by its weight and add the results. It is a dot product between a weight vector and a value vector.
1. Maths toolkit · Vectors: lists of numbers

Probability

Bayes' rule
A rule for turning a conditional probability around: P(H | E) = P(E | H) P(H) / P(E). It updates how likely a cause H is after you see evidence E.
1. Maths toolkit · Chance: probability and distributions
Bernoulli distribution
The distribution of one yes/no outcome: 1 with chance p, 0 with chance 1 − p.
3. ML fundamentals · Maximum likelihood and MAP
Beta distribution
A density over chances between 0 and 1, shaped by counts of successes and failures.
Not written yet · 5. Reinforcement learning · Smarter exploration: UCB and Thompson sampling
bias of an estimator
How far an estimate's average is from the true value. An unbiased estimate is right on average.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
categorical distribution
A distribution over a fixed list of outcomes (categories), with a probability for each. A spinner with any number of slices of any sizes.
1. Maths toolkit · Chance: probability and distributions
central limit theorem
The average (or sum) of many independent random values has a distribution close to a normal, for almost any shape of each value's own distribution.
1. Maths toolkit · Continuous chance: densities and the normal distribution
conditional independence
Two things are independent once you know a third: learning one tells you nothing more about the other.
3. ML fundamentals · Naive Bayes
conditional probability
The probability of A once you know B happened, written P(A | B). Zoom in on the cases where B happened and ask how often A happens among them: P(A | B) = P(A and B) / P(B).
1. Maths toolkit · Chance: probability and distributions
confidence interval
A range built from the data by a method that contains the true value in, say, 95% of repeated experiments.
3. ML fundamentals · A/B testing
continuous random variable
A random variable that can take any value in a range, like a delivery time of 31.7 minutes, rather than one of a list of separate values.
1. Maths toolkit · Continuous chance: densities and the normal distribution
covariance
How two quantities move together: positive if they rise together, negative if one falls as the other rises.
3. ML fundamentals · Principal component analysis
covariance matrix
A symmetric table of every pair of features' covariance, with variances on the diagonal. It describes a cloud's shape.
3. ML fundamentals · Principal component analysis
cross-entropy
H(p, q) = Σ p_i (−log q_i): the average surprise of a model q when outcomes follow p. Never less than the entropy H(p); equal only when q = p. The usual loss for classification.
1. Maths toolkit · Surprise: entropy, cross-entropy and KL divergence
cumulative distribution function
The cumulative distribution function F(x) = P(X ≤ x): the area under the density to the left of x. It rises from 0 to 1. P(a < X < b) = F(b) − F(a).
1. Maths toolkit · Continuous chance: densities and the normal distribution
distribution
The list of all possible outcomes of a random variable, with the probability of each. The probabilities add up to 1.
1. Maths toolkit · Chance: probability and distributions
entropy
The average surprise of a distribution: H(p) = Σ p_i (−log p_i). Zero when one outcome is certain; largest (log n) when all n outcomes are equally likely. Measures how unpredictable something is.
1. Maths toolkit · Surprise: entropy, cross-entropy and KL divergence
expectation as an integral
For a continuous random variable, E[X] = ∫ x p(x) dx: the area under x times the density. It is the weighted sum of the discrete case, with thin slices instead of separate values.
1. Maths toolkit · Continuous chance: densities and the normal distribution
expected value
The long-run average of a random variable: each value times its probability, added up. Written E[X]. It is the balance point of the distribution.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples
explaining away
When two causes share an effect, learning one cause happened makes the other less likely.
3. ML fundamentals · Bayesian networks
Hoeffding's bound
A guarantee that the average of n bounded samples is unlikely to be far from the true mean, with the gap shrinking like 1/√n.
Not written yet · 5. Reinforcement learning · Smarter exploration: UCB and Thompson sampling
hypothesis test
Assume there is no real effect, and ask whether the data would be surprising enough under that assumption to rule it out.
3. ML fundamentals · A/B testing
importance sampling
Estimate an average under one distribution from samples drawn from another, by weighting each sample by the ratio of their chances.
Not written yet · 5. Reinforcement learning · PPO: safe policy steps
incremental mean
Update an estimate one sample at a time: estimate ← estimate + α × (sample − estimate). With α = 1/n it gives exactly the sample mean.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples
independent
A and B are independent if knowing one tells you nothing about the other: P(A | B) = P(A). Then P(A and B) = P(A) × P(B).
1. Maths toolkit · Chance: probability and distributions
joint probability
The probability that two things both happen, written P(A and B). From a table of counts: the count in that cell divided by the total.
1. Maths toolkit · Chance: probability and distributions
KL divergence
KL(p ‖ q) = Σ p_i log(p_i / q_i) = H(p, q) − H(p): the extra average surprise from using q when outcomes follow p. Zero only when q = p, never negative, and not symmetric.
1. Maths toolkit · Surprise: entropy, cross-entropy and KL divergence
law of large numbers
As you average more and more independent samples, the sample mean tends to settle closer to the expected value.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples
likelihood
How probable the observed data is under particular parameter values, read as a function of the parameters.
3. ML fundamentals · Maximum likelihood and MAP
log-probability
The natural log of a probability, log p. It's 0 for a certain event and more negative for rarer ones. Products of probabilities become sums of log-probabilities, which stay in a comfortable range.
1. Maths toolkit · Scores to probabilities: argmax, softmax and log-probabilities
MAP estimate
The single most probable parameter value under the posterior. A prior on weights acts like regularisation.
3. ML fundamentals · Maximum likelihood and MAP
marginalisation
Getting the probability of some variables by adding up the joint probability over all values of the others.
3. ML fundamentals · Bayesian networks
Markov chain
A process that moves between a set of states in steps. At each step it picks the next state at random, with chances that depend only on the current state.
1. Maths toolkit · Memoryless randomness: Markov chains
Markov property
The next state depends only on the current state, not on how you got there: P(next | now, whole past) = P(next | now).
1. Maths toolkit · Memoryless randomness: Markov chains
maximum likelihood estimation
Choose the parameters that make the observed data most probable.
3. ML fundamentals · Maximum likelihood and MAP
mixing
How quickly a Markov chain forgets where it started and gets close to its stationary distribution. Set mostly by the second-largest eigenvalue: the closer it is to 1, the slower the mixing.
1. Maths toolkit · Memoryless randomness: Markov chains
Monte Carlo estimate
Estimate an expected value E[g(X)] by drawing samples of X and averaging g over them. The estimate tends to get closer as you add samples, for almost any distribution.
1. Maths toolkit · Continuous chance: densities and the normal distribution
multivariate normal distribution
The normal distribution in several dimensions: a bell-shaped hill whose contours are ellipses set by a covariance matrix.
3. ML fundamentals · Clustering: k-means and Gaussian mixtures
normal distribution
The bell-shaped distribution with mean μ and standard deviation σ, written N(μ, σ²). About 68% of its area is within 1σ of μ, and about 95% within 2σ.
1. Maths toolkit · Continuous chance: densities and the normal distribution
p-value
If there were no real effect, the chance of seeing a difference at least as big as the one observed, in either direction.
3. ML fundamentals · A/B testing
posterior
What you believe about a parameter after seeing the data: the prior updated by Bayes' rule.
3. ML fundamentals · Maximum likelihood and MAP
prior
What you believe about a parameter before seeing the data, as a distribution.
3. ML fundamentals · Maximum likelihood and MAP
probability
A number from 0 to 1 that says how often something happens in the long run: 0 means never, 1 means always. The probabilities of all possible outcomes add up to 1.
1. Maths toolkit · Chance: probability and distributions
probability density
A curve p(x) whose area over any interval is the probability of landing in it. Its height is probability per unit, not a probability, so it can be bigger than 1. The total area is 1.
1. Maths toolkit · Continuous chance: densities and the normal distribution
random variable
A number whose value comes from a chance process, like the time the next delivery takes. Written with a capital letter, such as T.
1. Maths toolkit · Chance: probability and distributions
reparameterisation trick
Write a random sample as μ + σ·ε with fixed-distribution noise ε, so gradients can flow into μ and σ.
Not written yet · 5. Reinforcement learning · TD3 and SAC
sample mean
The plain average of the samples you've seen: add them up and divide by how many there are. An estimate of the expected value.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples
standard deviation
The square root of the variance, written σ. It measures spread in the same units as the values themselves: a typical distance from the mean.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples
standard error
How much an estimate such as a sample mean or a rate would wobble from sample to sample: its standard deviation.
3. ML fundamentals · A/B testing
stationary distribution
A distribution d over the states that one step of the chain leaves unchanged: d T = d. For a well-behaved chain, it's where the chances settle from any start, and the long-run share of time spent in each state.
1. Maths toolkit · Memoryless randomness: Markov chains
statistical power
The chance an experiment comes out significant when an effect of a given size is there. More samples give more power.
3. ML fundamentals · A/B testing
step size
The fraction α of the error that an incremental update moves the estimate by. α = 1/n gives the plain average; a constant α weights recent samples more. Called the learning rate when training models.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples
surprise
How surprising an outcome with probability p is: −log p. Zero for a certain event, large for a rare one, and the surprises of independent events add up. Also called information content.
1. Maths toolkit · Surprise: entropy, cross-entropy and KL divergence
transition matrix
A square table T where row i, column j holds the chance of moving from state i to state j in one step. Each row is a probability distribution, so it adds up to 1.
1. Maths toolkit · Memoryless randomness: Markov chains
uniform distribution
The flat distribution on a range [a, b]: every value in the range is equally likely. Its density is 1 / (b − a) inside the range and 0 outside. Written U(a, b).
1. Maths toolkit · Continuous chance: densities and the normal distribution
variance
The expected squared distance from the mean: Var(X) = E[(X − E[X])²]. Large when values often land far from the mean. Its units are squared.
1. Maths toolkit · Averages you can trust: expectation, variance and learning from samples

Neural networks

activation function
A simple nonlinear function applied after a weighted sum, like ReLU. Without it, stacked layers collapse into one linear layer.
4. Neural-net foundations · From logistic regression to a neuron
attention
Each item scores every item (dot products, then softmax) and outputs a weighted average of them, so every item sees every other item in one step.
4. Neural-net foundations · Sequences: recurrence and attention
autoencoder
A network trained to reproduce its input through a narrow middle layer, so it must learn a compact code.
4. Neural-net foundations · Embeddings and autoencoders
backpropagation
Computing every weight's gradient by running the chain rule backwards through the network, from the loss to the inputs, reusing each shared part once.
4. Neural-net foundations · Backpropagation
backward pass
The run back through a network after the forward pass. It turns the loss's gradient into every weight's gradient, multiplying by local gradients along the way.
4. Neural-net foundations · Backpropagation
batch normalisation
Standardise each unit over the batch (subtract the batch mean, divide by the batch standard deviation), then apply a learned scale and shift. Uses running averages at test time.
4. Neural-net foundations · Making deep networks train
bottleneck
A deliberately narrow layer that forces a network to squeeze information into a few numbers.
4. Neural-net foundations · Embeddings and autoencoders
convolution
Slide a small grid of weights over an input and take a weighted sum at each position.
4. Neural-net foundations · Grids and images: convolutions
convolutional network (CNN)
A network built mostly from convolution layers, used for images and other grids.
4. Neural-net foundations · Grids and images: convolutions
dropout
During training, zero each unit's output with probability p and scale the survivors by 1/(1 − p), so the network can't rely on any single unit. Off in evaluation mode.
4. Neural-net foundations · Keeping networks general
embedding
A learned vector for each category (word, topping, user), stored as one row of a table. Similar categories end up with similar vectors.
4. Neural-net foundations · Embeddings and autoencoders
equivariance
Shift the input and the output shifts the same way. Convolutions are equivariant to moving an image.
4. Neural-net foundations · Why a network's shape matters
Exploding gradients
Gradients growing huge as they flow back through many layers, so steps are wild and training is unstable. Caused by repeated multiplication by numbers bigger than 1.
4. Neural-net foundations · Making deep networks train
feature map
The grid of outputs from one filter: how strongly its pattern appears at each position.
4. Neural-net foundations · Grids and images: convolutions
filter
The small grid of learned weights a convolution slides across its input. Each one detects one kind of pattern.
4. Neural-net foundations · Grids and images: convolutions
forward pass
Running inputs through a network, layer by layer, to get its output.
4. Neural-net foundations · Feedforward networks
GELU
A smooth version of ReLU, used in transformers.
4. Neural-net foundations · From logistic regression to a neuron
graph neural network (GNN)
A network for data shaped like a graph, such as molecules or road maps, where each node learns from its neighbours.
4. Neural-net foundations · Graphs, and choosing a primitive
hidden layer
A layer between the input and the output.
4. Neural-net foundations · Feedforward networks
hidden state
The running memory a recurrent network carries from one step of a sequence to the next.
4. Neural-net foundations · Sequences: recurrence and attention
inductive bias
The assumptions built into a model's shape, like 'nearby pixels matter together'. Good ones need less data.
4. Neural-net foundations · Why a network's shape matters
invariance
Change the input in some way and the output stays the same, like a cat detector that doesn't care where the cat is.
4. Neural-net foundations · Why a network's shape matters
latent space
The space of the compact codes a network learns, where nearby points mean similar inputs.
4. Neural-net foundations · Embeddings and autoencoders
layer
Many neurons side by side that read the same inputs. In code: a matrix multiply, plus a bias, then an activation.
4. Neural-net foundations · Feedforward networks
layer normalisation
Standardise each example's units (subtract their mean, divide by their standard deviation), then apply a learned scale and shift. Works the same in training and testing; used in transformers.
4. Neural-net foundations · Making deep networks train
linear layers collapse
Stacking linear layers with no activation in between gives just one linear layer, so depth adds nothing.
4. Neural-net foundations · From logistic regression to a neuron
local gradient
The slope of one step's output with respect to one of its own inputs. Backprop multiplies these together along each path.
4. Neural-net foundations · Backpropagation
logits
A network's raw output scores, before softmax turns them into probabilities.
4. Neural-net foundations · Feedforward networks
message passing
One GNN step: every node gathers its neighbours' vectors, combines them, and updates its own.
4. Neural-net foundations · Graphs, and choosing a primitive
multilayer perceptron (MLP)
A network of layers stacked one after another, each feeding the next.
4. Neural-net foundations · Feedforward networks
neuron
A weighted sum of inputs plus a bias, passed through an activation function.
4. Neural-net foundations · From logistic regression to a neuron
overfitting one batch
A sanity check: train on one small batch only. A working model, loss and loop drive its loss close to 0; if they can't, there's a bug.
4. Neural-net foundations · Debugging training
receptive field
The patch of the original input that one unit can see. It grows with every convolution layer.
4. Neural-net foundations · Grids and images: convolutions
recurrent neural network (RNN)
A recurrent neural network: it reads a sequence one item at a time, updating a hidden state with the same weights at every step.
4. Neural-net foundations · Sequences: recurrence and attention
ReLU
max(0, x): keep positive numbers, replace negatives with 0. The most common activation function.
4. Neural-net foundations · From logistic regression to a neuron
sigmoid
The S-shaped function 1 / (1 + e^(−x)). It squashes any number into the range 0 to 1, so it can be a probability.
3. ML fundamentals · Logistic regression and classification
softmax
Turns a list of scores into probabilities: take exp of each score, then divide by the total. Bigger scores get bigger probabilities, every probability is positive, and they add up to 1.
1. Maths toolkit · Scores to probabilities: argmax, softmax and log-probabilities
tanh
An S-shaped function that squashes any number into the range −1 to 1.
4. Neural-net foundations · From logistic regression to a neuron
temperature
A positive number τ that divides the scores before softmax. Below 1 it sharpens the probabilities towards argmax; above 1 it flattens them towards an even split; τ = 1 is plain softmax.
1. Maths toolkit · Scores to probabilities: argmax, softmax and log-probabilities
training loop
The repeated cycle of take a batch, clear gradients, forward, loss, backward, step, with regular checks on validation data.
4. Neural-net foundations · The training loop, properly
universal approximation
A network with one big enough hidden layer can approximate any reasonable function.
4. Neural-net foundations · Feedforward networks
Vanishing gradients
Gradients shrinking towards zero as they flow back through many layers, so the early layers barely learn. Caused by repeated multiplication by numbers smaller than 1.
4. Neural-net foundations · Making deep networks train
variational autoencoder (VAE)
An autoencoder whose code is a probability distribution, trained with a reconstruction loss plus a KL divergence term.
Not written yet · 10. Autoencoders · Variational autoencoders
weight initialisation
How a network's weights are set before training: random, so units differ, and scaled by about 1/√fan-in (√2/√fan-in for ReLU), so signals keep their size through the layers.
4. Neural-net foundations · Making deep networks train
weight sharing
Using the same weights at many positions, so a pattern learned in one place is recognised everywhere.
4. Neural-net foundations · Why a network's shape matters

Machine learning

`model.train()` and `model.eval()`
The switch between a model's training behaviour and its testing behaviour, for layers like dropout and batch norm: model.train() and model.eval().
4. Neural-net foundations · The training loop, properly
A/B test
Randomly split customers between the old version (A) and a new one (B), and compare a number such as an on-time rate between the groups.
3. ML fundamentals · A/B testing
accuracy
The share of examples a classifier gets right. Misleading when one class is rare.
3. ML fundamentals · Measuring success
AUC
The area under the ROC curve: the chance a random positive gets a higher score than a random negative.
3. ML fundamentals · Measuring success
bag of words
Describe a text by how often each word appears, ignoring word order.
3. ML fundamentals · Naive Bayes
Bagging
Train many models on bootstrap samples and average them. It cuts variance.
3. ML fundamentals · Bagging and random forests
baseline
The simplest sensible model, such as 'predict the average' or 'always the commonest class'. A real model must beat it to be worth anything.
3. ML fundamentals · Choosing a model for tabular data
Bayesian network
A graph of variables where arrows show direct influence; each variable has a table of chances given its parents.
3. ML fundamentals · Bayesian networks
bias–variance trade-off
Error from a model too rigid to fit the pattern (bias) traded against error from fitting each sample's noise (variance). More capacity lowers bias and raises variance.
3. ML fundamentals · Generalisation and overfitting
boosting
Build models one after another, each focusing on the mistakes of the ones before. It cuts bias.
3. ML fundamentals · Boosting and gradient-boosted trees
bootstrap sample
A same-sized sample drawn from the data with replacement, so some examples repeat and some are left out.
3. ML fundamentals · Bagging and random forests
calibration
Whether predicted probabilities match how often things happen: of the deliveries given 0.8, about 80% should be late.
3. ML fundamentals · Measuring success
capacity
How flexible a model is: how many different patterns it can fit. More capacity fits more, including noise.
3. ML fundamentals · Generalisation and overfitting
class imbalance
When one class is much rarer than another, which makes accuracy misleading and training harder.
3. ML fundamentals · Measuring success
classification
Predicting which of a fixed set of categories an example belongs to, like late or on time.
3. ML fundamentals · Logistic regression and classification
clustering
Grouping examples so that each group's members are similar to each other, with no labels to say what the groups are.
3. ML fundamentals · Clustering: k-means and Gaussian mixtures
confusion matrix
A table counting true positives, false positives, false negatives and true negatives.
3. ML fundamentals · Measuring success
cross-entropy loss
The usual loss for classification: minus the log of the probability the model gave the right answer.
3. ML fundamentals · Logistic regression and classification
cross-validation
Split the training data into k folds; train on k − 1 of them and validate on the last, k times, so each fold is validated once; average the k scores.
3. ML fundamentals · Regularisation and cross-validation
curse of dimensionality
With many features, every point is far from every other, so 'nearest' stops meaning much.
3. ML fundamentals · Nearest neighbours
data leakage
Information the model wouldn't have at prediction time sneaking into training, so validation scores look too good.
3. ML fundamentals · Features, leakage and the workflow
dataset
The collection of examples a model learns from or is tested on. Each example has features and, in supervised learning, a label.
3. ML fundamentals · Learning from examples
decision boundary
The line or curve where a classifier switches from one class to the other.
3. ML fundamentals · Logistic regression and classification
decision threshold
The probability above which a classifier says 'positive'. Moving it trades precision against recall.
3. ML fundamentals · Measuring success
decision tree
A flowchart of yes/no questions about features. Each leaf gives a prediction.
3. ML fundamentals · Decision trees
dimensionality reduction
Describing each example with fewer numbers while keeping as much of the useful information as possible.
3. ML fundamentals · Principal component analysis
discriminative model
A model of P(class | features) directly, like logistic regression, without modelling the features themselves.
3. ML fundamentals · Naive Bayes
distribution shift
When the data a model sees in use differs from the data it was trained on, so its accuracy can quietly drop.
3. ML fundamentals · Evaluation you can trust
early stopping
Stop training when the validation score stops improving, and keep the best version so far.
3. ML fundamentals · Boosting and gradient-boosted trees
ensemble
Several models whose predictions are combined, by voting or averaging, into one.
3. ML fundamentals · Bagging and random forests
epoch
One full pass over the training data.
3. ML fundamentals · Gradient descent
expectation–maximisation (EM) algorithm
Fit a model with hidden parts by alternating: guess the hidden parts (E step), then refit the parameters (M step).
3. ML fundamentals · Clustering: k-means and Gaussian mixtures
explained variance
The share of the data's total spread that a principal component captures: its eigenvalue over the sum of all of them.
3. ML fundamentals · Principal component analysis
F1 score
One number combining precision and recall (their harmonic mean). High only when both are high.
3. ML fundamentals · Measuring success
feature engineering
Building better input features from raw data, like 'is it rush hour' from a timestamp.
3. ML fundamentals · Features, leakage and the workflow
feature importance
How much a model relies on each feature, for example how much the score drops when that feature is shuffled.
3. ML fundamentals · Bagging and random forests
feature scaling
Putting features on similar scales, usually by subtracting the mean and dividing by the standard deviation.
3. ML fundamentals · Nearest neighbours
features
One measured number that describes an example, like distance or traffic level for a delivery. A list of features is a feature vector.
1. Maths toolkit · Vectors: lists of numbers
Gaussian mixture model
Data modelled as coming from several normal distributions, each with its own centre, shape and share.
3. ML fundamentals · Clustering: k-means and Gaussian mixtures
Gaussian process
A model that puts a probability distribution over whole functions, using a kernel to say which points move together.
3. ML fundamentals · Support vector machines and kernels
generalisation
How well a model does on new examples it wasn't trained on. It's what we actually care about.
3. ML fundamentals · Generalisation and overfitting
generative model
A model of how the data is produced, P(features | class) and P(class), that can also classify with Bayes' rule.
3. ML fundamentals · Naive Bayes
Gini impurity
How mixed a group's labels are: the chance two random picks from it disagree. 0 means pure.
3. ML fundamentals · Decision trees
gradient boosting
Boosting where each new model is fitted to the residuals (more generally, the negative gradient of the loss).
3. ML fundamentals · Boosting and gradient-boosted trees
gradient-boosted trees
Gradient boosting with small decision trees, as in XGBoost and LightGBM. The usual winner on tables of data.
3. ML fundamentals · Boosting and gradient-boosted trees
group split
Keep all examples from one group (a customer, a patient, a driver) on the same side of the split, so the score says how the model does on new groups.
3. ML fundamentals · Evaluation you can trust
hinge loss
A loss that is zero for examples safely on the right side of the margin and grows linearly otherwise.
3. ML fundamentals · Support vector machines and kernels
Huber loss
A loss that is squared for small errors and grows linearly for large ones, so outliers pull less.
Not written yet · 5. Reinforcement learning · Deep Q-networks
hyperparameter
A setting you choose before training, like the learning rate, rather than one the model learns.
3. ML fundamentals · Gradient descent
hyperparameter search
Trying many hyperparameter settings and keeping the one with the best validation (often cross-validation) score.
3. ML fundamentals · Regularisation and cross-validation
information gain
How much a split lowers the entropy of the labels. Trees pick the split that lowers it most.
3. ML fundamentals · Decision trees
intercept
The constant b in w · x + b: the prediction when every feature is 0. Also called the bias.
3. ML fundamentals · Linear regression
k-means
Repeat: assign each point to its nearest centre, then move each centre to the mean of its points.
3. ML fundamentals · Clustering: k-means and Gaussian mixtures
k-nearest neighbours
Predict for a new example from the k most similar training examples: their majority class or average value.
3. ML fundamentals · Nearest neighbours
kernel
A similarity function between two examples that acts like a dot product in some bigger feature space.
3. ML fundamentals · Support vector machines and kernels
kernel trick
Swap every dot product for a kernel, and a linear method draws curved boundaries without building the big features.
3. ML fundamentals · Support vector machines and kernels
L1 regularisation
Add λ times the sum of the weights' sizes (absolute values) to the loss. It pushes some weights to exactly zero, which drops their features. Also called lasso.
3. ML fundamentals · Regularisation and cross-validation
L2 regularisation
Add (λ/2) times the sum of squared weights to the loss. It shrinks every weight towards zero, but never all the way. Also called ridge.
3. ML fundamentals · Regularisation and cross-validation
label
The answer we want a model to predict for an example, like a delivery's time in minutes. Also called the target.
3. ML fundamentals · Learning from examples
Laplace smoothing
Add one pretend count to every word so an unseen word doesn't make a probability exactly zero.
3. ML fundamentals · Naive Bayes
least squares
Solving for the weights that make the squared error smallest in one step, with linear algebra instead of many small steps.
3. ML fundamentals · Linear regression
linear model
A model whose prediction is a weighted sum of the features plus a constant: w · x + b.
3. ML fundamentals · Linear regression
linear regression
Fitting a linear model to numbers by making the mean squared error as small as possible.
3. ML fundamentals · Linear regression
linearly separable
Data whose classes can be split perfectly by a straight line (or flat plane).
3. ML fundamentals · Logistic regression and classification
logistic regression
A linear score passed through the sigmoid, giving the probability of the positive class. Trained with cross-entropy loss.
3. ML fundamentals · Logistic regression and classification
loss curve
A plot of the loss against training steps. It shows whether, and how fast, training is working.
3. ML fundamentals · Gradient descent
loss function
A single number that measures how wrong a model's predictions are. Training tries to make it small.
3. ML fundamentals · Learning from examples
margin
The gap between the decision boundary and the closest training examples.
3. ML fundamentals · Support vector machines and kernels
mean absolute error
The average size of the mistakes, ignoring their sign. One wild example pulls it less than it pulls the MSE.
3. ML fundamentals · Linear regression
mean squared error
A loss: the average of (prediction − target)². Big mistakes count much more than small ones.
3. ML fundamentals · Linear regression
Missing values
Blank entries in the data. You fill them (imputation) or flag them, using only training data to decide how.
3. ML fundamentals · Features, leakage and the workflow
model
A rule with adjustable numbers that turns an example's features into a prediction.
3. ML fundamentals · Learning from examples
naive Bayes
A classifier that applies Bayes' rule and assumes the features are independent given the class.
3. ML fundamentals · Naive Bayes
negative log-likelihood
Minus the log of the likelihood. Minimising it is maximum likelihood; MSE and cross-entropy are special cases.
3. ML fundamentals · Maximum likelihood and MAP
non-parametric model
A model that keeps the training data (or grows with it) instead of summarising it in a fixed set of weights.
3. ML fundamentals · Nearest neighbours
one-hot encoding
Turn a category into a vector with a 1 in its own slot and 0s elsewhere, so a model can use it as numbers.
3. ML fundamentals · Features, leakage and the workflow
out-of-bag error
Each tree's score on the examples its bootstrap sample left out: a free validation estimate.
3. ML fundamentals · Bagging and random forests
overfitting
Fitting the training examples so closely, noise included, that the model does worse on new examples.
3. ML fundamentals · Generalisation and overfitting
parameters
The numbers a model learns, like the weights in w · x + b. Training adjusts them to make predictions better.
3. ML fundamentals · Learning from examples
pipeline
A fixed sequence of preprocessing steps plus a model, fitted together on training data only.
3. ML fundamentals · Features, leakage and the workflow
polynomial features
Extra features made from powers of the original ones, like distance², so a linear model can fit curves.
3. ML fundamentals · Generalisation and overfitting
precision
Of the examples flagged positive, the share that really are positive.
3. ML fundamentals · Measuring success
principal component analysis
Find the directions in which data spreads out most (the covariance matrix's eigenvectors), and keep the top few.
3. ML fundamentals · Principal component analysis
probabilistic inference
Working out the probability of unobserved variables given the ones you have observed.
3. ML fundamentals · Bayesian networks
pruning
Limiting or cutting back a tree (by depth or leaf size) so it doesn't grow a leaf for every noisy example.
3. ML fundamentals · Decision trees
random forest
Bagged decision trees that also pick from a random subset of features at each split, so the trees differ more.
3. ML fundamentals · Bagging and random forests
RBF kernel
The Gaussian kernel exp(−γ‖x − x′‖²): similarity that fades with distance. γ sets how fast.
3. ML fundamentals · Support vector machines and kernels
recall
Of the examples that really are positive, the share the model flagged.
3. ML fundamentals · Measuring success
regression
Predicting a number, like a delivery time, rather than a category.
3. ML fundamentals · Learning from examples
regularisation
Anything that discourages a model from fitting noise, usually a penalty on large weights added to the loss.
3. ML fundamentals · Regularisation and cross-validation
residual
How far one prediction is from the true value: target minus prediction.
3. ML fundamentals · Linear regression
ROC curve
True-positive rate against false-positive rate as the threshold sweeps from 1 to 0.
3. ML fundamentals · Measuring success
soft assignment
Giving each point a probability of belonging to each cluster, instead of exactly one cluster.
3. ML fundamentals · Clustering: k-means and Gaussian mixtures
softmax regression
Logistic regression for more than two classes: one linear score per class, turned into probabilities by softmax.
3. ML fundamentals · Logistic regression and classification
supervised learning
Learning from examples that come with the right answer, so the model can learn to predict the answer for new examples.
3. ML fundamentals · Learning from examples
support vector machine
A classifier that picks the boundary with the widest margin to the nearest examples of each class.
3. ML fundamentals · Support vector machines and kernels
support vectors
A training example on or inside the margin. Only these examples decide where the boundary goes.
3. ML fundamentals · Support vector machines and kernels
time-based split
Train on the past and test on the future, so the model never learns from data it couldn't have had at prediction time.
3. ML fundamentals · Evaluation you can trust
train, validation and test sets
Split the data three ways: fit on the training set, choose settings on the validation set, and report the final score once on the test set.
3. ML fundamentals · Generalisation and overfitting
training
Adjusting a model's parameters, using examples, so its loss gets smaller.
3. ML fundamentals · Learning from examples
underfitting
A model too simple to capture the pattern, so it does badly even on its training examples.
3. ML fundamentals · Generalisation and overfitting
unsupervised learning
Finding structure in data that comes with no labels, such as groups or main directions of spread.
3. ML fundamentals · Principal component analysis

Reinforcement learning

A2C
Advantage actor–critic: several environment copies step together, and the actor learns from advantage estimates.
Not written yet · 5. Reinforcement learning · Actor–critic
action
One of the choices the agent can make in a state, such as moving north.
Not written yet · 5. Reinforcement learning · Learning by trial and error
action value
Q^π(s, a): the expected return from taking action a in state s, then following policy π.
Not written yet · 5. Reinforcement learning · Action values and the best policy
actor
The policy part of an actor–critic method: it picks the actions.
Not written yet · 5. Reinforcement learning · Actor–critic
actor–critic
A policy (the actor) trained with a signal from a learned value function (the critic).
Not written yet · 5. Reinforcement learning · Actor–critic
advantage
A(s, a) = Q(s, a) − V(s): how much better an action is than the policy's average in that state.
Not written yet · 5. Reinforcement learning · Actor–critic
agent
The learner and decision-maker: it sees the state, picks an action and receives a reward.
Not written yet · 5. Reinforcement learning · Learning by trial and error
backup
Computing a state's value from the rewards and values one step ahead, pictured as a small tree under the state.
Not written yet · 5. Reinforcement learning · Values and the Bellman equation
bandit
Repeated choices between options of unknown worth, with no state: learn which option pays best by trying them.
Not written yet · 5. Reinforcement learning · Bandits: explore or exploit
baseline
A number subtracted from the return in a policy gradient. It reduces noise without changing the expected gradient.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
behaviour policy
The policy that actually picks the actions while learning, usually an exploring one.
Not written yet · 5. Reinforcement learning · Q-learning: learning the best while exploring
belief MDP
Treat beliefs as states: a POMDP becomes an MDP over beliefs, which are continuous.
Not written yet · 5. Reinforcement learning · When you can't see the state: POMDPs
belief state
A probability distribution over the hidden states, given everything seen so far.
Not written yet · 5. Reinforcement learning · When you can't see the state: POMDPs
belief update
Bayes' rule applied after each action and observation to get the new belief.
Not written yet · 5. Reinforcement learning · When you can't see the state: POMDPs
Bellman expectation equation
A state's value under a policy is the expected reward now plus γ times the expected value of the next state.
Not written yet · 5. Reinforcement learning · Values and the Bellman equation
Bellman operator
The update that turns one guess of the values into the next: V ↦ max over actions of r + γ T V.
Not written yet · 5. Reinforcement learning · Value iteration
Bellman optimality equation
The best value of a state is the best action's expected reward now plus γ times the best value of the next state.
Not written yet · 5. Reinforcement learning · Action values and the best policy
bootstrapping
Updating an estimate using another estimate, such as the next state's current value, instead of a full return.
Not written yet · 5. Reinforcement learning · Temporal-difference learning
clipped double Q
Use the smaller of two critics' estimates in the target, to fight over-optimism.
Not written yet · 5. Reinforcement learning · TD3 and SAC
continuing task
A task that never ends, such as a customer ordering every week. Discounting keeps its return finite.
Not written yet · 5. Reinforcement learning · Returns and discounting
continuous actions
Actions that are real numbers, such as a torque, rather than one of a few choices.
Not written yet · 5. Reinforcement learning · Continuous actions: DDPG
contraction
A map that brings any two inputs closer together. The Bellman update shrinks the gap between two value guesses by at least γ.
Not written yet · 5. Reinforcement learning · Value iteration
credit assignment
Working out which earlier actions deserve credit (or blame) for a reward that arrives later.
Not written yet · 5. Reinforcement learning · Learning by trial and error
critic
The value part of an actor–critic method: it estimates how good states or actions are.
Not written yet · 5. Reinforcement learning · Actor–critic
DDPG
Deep deterministic policy gradient: DQN's ideas for continuous actions, with an actor that climbs the critic.
Not written yet · 5. Reinforcement learning · Continuous actions: DDPG
deadly triad
Function approximation, bootstrapping and off-policy learning together, which can make values diverge.
Not written yet · 5. Reinforcement learning · Values from features
deep Q-network (DQN)
Q-learning with a neural network for Q, steadied by a replay buffer and a target network.
Not written yet · 5. Reinforcement learning · Deep Q-networks
deterministic policy gradient
Train a deterministic actor by following the critic's slope with respect to the action.
Not written yet · 5. Reinforcement learning · Continuous actions: DDPG
discount factor
A number γ between 0 and 1 that shrinks rewards further in the future, so a reward k steps away counts γ^k as much.
Not written yet · 5. Reinforcement learning · Returns and discounting
Double DQN
DQN where the online network picks the next action and the target network values it.
Not written yet · 5. Reinforcement learning · Over-optimism and Double DQN
double Q-learning
Use one set of estimates to choose the best action and a second, independent set to value it.
Not written yet · 5. Reinforcement learning · Over-optimism and Double DQN
Dyna
Q-learning plus a learned model: after each real step, replay imagined steps from the model to update Q more.
Not written yet · 5. Reinforcement learning · Learning a model: Dyna
effective horizon
About how many steps ahead the agent really looks: 1/(1 − γ), so 10 steps at γ = 0.9.
Not written yet · 5. Reinforcement learning · Returns and discounting
eligibility trace
A fading record of recently visited states, so a TD error updates each of them in proportion to how recently it was visited.
Not written yet · 5. Reinforcement learning · n-step returns and TD(λ)
entropy bonus
A reward for keeping the policy spread out, which keeps it exploring.
Not written yet · 5. Reinforcement learning · PPO: safe policy steps
environment
Everything outside the agent: it takes the agent's action and answers with the next state and a reward.
Not written yet · 5. Reinforcement learning · Learning by trial and error
episode
One run from a start state until a terminal state, like one game from start to finish.
Not written yet · 5. Reinforcement learning · Learning by trial and error
episodic task
A task that ends, in a terminal state, and then starts again: a game, a maze.
Not written yet · 5. Reinforcement learning · Returns and discounting
evaluative feedback
Feedback that says how good the outcome was, not what the right action would have been.
Not written yet · 5. Reinforcement learning · Learning by trial and error
every-visit Monte Carlo
Monte Carlo that uses the return after every visit to a state, even several in one episode.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
exploration noise
Random noise added to a deterministic actor's action so it tries nearby actions.
Not written yet · 5. Reinforcement learning · Continuous actions: DDPG
exploration–exploitation trade-off
Choosing between trying options to learn more (explore) and using the best one found so far (exploit).
Not written yet · 5. Reinforcement learning · Bandits: explore or exploit
first-visit Monte Carlo
Monte Carlo that uses only the return after a state's first visit in each episode.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
function approximation
Predicting values from features with a function, such as a linear model or network, instead of a table.
Not written yet · 5. Reinforcement learning · Values from features
generalised advantage estimation
An advantage estimate that blends TD errors over many steps with a λ dial, like TD(λ) for advantages.
Not written yet · 5. Reinforcement learning · Actor–critic
generalised policy iteration
The general pattern behind most RL: values chase the policy, the policy chases the values, until both settle.
Not written yet · 5. Reinforcement learning · Policy iteration
GLIE
Greedy in the limit with infinite exploration: explore forever, but less and less, so the policy ends up greedy.
Not written yet · 5. Reinforcement learning · SARSA: learning to act
gradient bandit
A bandit method that keeps a preference per arm, picks by softmax, and moves preferences by a policy gradient.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
greedy policy
Always pick the action with the highest estimated value in the current state.
Not written yet · 5. Reinforcement learning · Action values and the best policy
imitation learning
Learning a policy by copying an expert's demonstrated actions.
Not written yet · 5. Reinforcement learning · Learning what to want
inverse reinforcement learning
Inferring the reward function that an expert's behaviour seems to be maximising.
Not written yet · 5. Reinforcement learning · Learning what to want
learned model
An estimate of the environment's transitions and rewards, built from the agent's own experience.
Not written yet · 5. Reinforcement learning · Learning a model: Dyna
linear value function
A value estimate that is a weighted sum of the state's features: V(s) = w · x(s).
Not written yet · 5. Reinforcement learning · Values from features
living reward
A small reward (often negative) for every step that doesn't end the episode.
Not written yet · 5. Reinforcement learning · Designing rewards
log-derivative trick
∇p = p ∇log p, which turns the gradient of an expected value into an expected value you can estimate by sampling.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
Markov decision process
A Markov chain in which an agent picks an action at each step, and the action changes the transition chances and earns a reward.
Not written yet · 5. Reinforcement learning · Markov decision processes
maximisation bias
Taking the max of noisy estimates gives a number that is too high on average.
Not written yet · 5. Reinforcement learning · Over-optimism and Double DQN
maximum-entropy RL
Maximise return plus a bonus for the policy's entropy, so the agent stays as random as it can while doing well.
Not written yet · 5. Reinforcement learning · TD3 and SAC
model-based
Methods that use a model of T and r, given or learned, to plan.
Not written yet · 5. Reinforcement learning · Learning a model: Dyna
model-free
Methods that learn values or policies from experience, without knowing or learning T and r.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
Monte Carlo control
Improving a policy using action values estimated by averaging whole-episode returns.
Not written yet · 5. Reinforcement learning · SARSA: learning to act
Monte Carlo prediction
Estimate how good a state is by averaging the returns actually seen after visiting it.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
Monte Carlo tree search
Plan by growing a search tree with simulated games, spending more simulations on promising moves.
Not written yet · 5. Reinforcement learning · Planning by search: MCTS
n-step return
The real rewards for the next n steps, plus the discounted estimate of the state reached after them.
Not written yet · 5. Reinforcement learning · n-step returns and TD(λ)
observation function
O(o | s′, a): the chance of seeing observation o after action a lands in state s′.
Not written yet · 5. Reinforcement learning · When you can't see the state: POMDPs
off-policy
Learning about one policy (the target) from actions chosen by another (the behaviour policy).
Not written yet · 5. Reinforcement learning · Q-learning: learning the best while exploring
on-policy
Learning the values of the same policy that is choosing the actions, exploration included.
Not written yet · 5. Reinforcement learning · SARSA: learning to act
optimal policy
A policy that gets the highest expected return from every state; acting greedily on Q* gives one.
Not written yet · 5. Reinforcement learning · Action values and the best policy
optimal value
V*(s) and Q*(s, a): the best expected return any policy can get from a state, or from a state and action.
Not written yet · 5. Reinforcement learning · Action values and the best policy
optimism under uncertainty
Prefer options you're unsure about, as if they're as good as they plausibly could be.
Not written yet · 5. Reinforcement learning · Smarter exploration: UCB and Thompson sampling
optimistic initialisation
Start every estimate high, so untried options look good and get tried.
Not written yet · 5. Reinforcement learning · Bandits: explore or exploit
option
A temporally extended action: a small policy with where it can start and when it stops, such as "go to the door".
Not written yet · 5. Reinforcement learning · Options: thinking in bigger steps
plan
A fixed sequence of actions chosen in advance. Unlike a policy, it can't react to what actually happens.
Not written yet · 5. Reinforcement learning · Markov decision processes
planning step
One update made from the model instead of from the real environment.
Not written yet · 5. Reinforcement learning · Learning a model: Dyna
policy
An agent's rule for choosing actions: for each state, a probability for each action.
Not written yet · 5. Reinforcement learning · Markov decision processes
policy evaluation
Working out V^π for a fixed policy, for example by solving its Bellman equations as a linear system.
Not written yet · 5. Reinforcement learning · Policy iteration
policy gradient
Training a policy directly: nudge its parameters so that actions which led to high reward become more likely.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
policy gradient theorem
The gradient of expected return is the expected return-weighted gradient of the log-probability of the actions taken.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
policy improvement
Making a policy greedy with respect to its own values. The new policy is never worse.
Not written yet · 5. Reinforcement learning · Policy iteration
policy iteration
Alternate policy evaluation and policy improvement until the policy stops changing.
Not written yet · 5. Reinforcement learning · Policy iteration
POMDP
Partially observable MDP: the agent gets observations that only hint at the hidden state.
Not written yet · 5. Reinforcement learning · When you can't see the state: POMDPs
potential-based shaping
Shaping of the form γΦ(s′) − Φ(s). It speeds up learning without changing the best policy.
Not written yet · 5. Reinforcement learning · Designing rewards
PPO clipped objective
PPO's loss: the ratio times the advantage, with the ratio clipped to [1 − ε, 1 + ε] so big moves earn nothing extra.
Not written yet · 5. Reinforcement learning · PPO: safe policy steps
prediction and control
Prediction estimates the values of a given policy; control looks for a better policy.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
preference learning
Learning a reward from people's choices between pairs of trajectories or outputs.
Not written yet · 5. Reinforcement learning · Learning what to want
probability ratio
The new policy's chance of an action divided by the old policy's chance of it.
Not written yet · 5. Reinforcement learning · PPO: safe policy steps
Q-learning
TD control that updates Q(S, A) toward R + γ max over a′ of Q(S′, a′), learning the greedy policy while exploring.
Not written yet · 5. Reinforcement learning · Q-learning: learning the best while exploring
regret
How much reward was lost compared with always making the best choice.
Not written yet · 5. Reinforcement learning · Bandits: explore or exploit
REINFORCE
The basic policy-gradient method: after each episode, raise the log-probability of each action in proportion to the return that followed.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
replay buffer
A store of past transitions that training samples from at random, breaking up runs of similar steps.
Not written yet · 5. Reinforcement learning · Deep Q-networks
return
The total future reward from a time step on, with each later reward shrunk by the discount factor: G = R₁ + γR₂ + γ²R₃ + …
Not written yet · 5. Reinforcement learning · Returns and discounting
reward
The number the environment gives after each step. The agent's goal is to collect as much as possible over time.
Not written yet · 5. Reinforcement learning · Learning by trial and error
reward function
r(s, a, s′): the expected reward for moving from s to s′ with action a.
Not written yet · 5. Reinforcement learning · Markov decision processes
reward hacking
When an agent finds a way to score high reward that the designer didn't intend.
Not written yet · 5. Reinforcement learning · Designing rewards
reward model
A learned function that predicts the reward people would give, used in place of a hand-written reward.
Not written yet · 5. Reinforcement learning · Learning what to want
reward scaling
Multiplying every reward by the same positive number: values scale too, but the best policy doesn't change.
Not written yet · 5. Reinforcement learning · Designing rewards
reward shaping
Adding extra rewards to guide learning toward the goal faster.
Not written yet · 5. Reinforcement learning · Designing rewards
Robbins–Monro conditions
Conditions on the step sizes that make an incremental estimate settle on the right answer: steps must add to infinity, but their squares must not.
Not written yet · 5. Reinforcement learning · Monte Carlo: learning from whole episodes
rollout
A quick simulated play-out from a position to the end, used to estimate how good the position is.
Not written yet · 5. Reinforcement learning · Planning by search: MCTS
SAC
Soft actor–critic: off-policy actor–critic that maximises reward plus the policy's entropy.
Not written yet · 5. Reinforcement learning · TD3 and SAC
sample efficiency
How much real experience a method needs to learn a good policy.
Not written yet · 5. Reinforcement learning · Learning a model: Dyna
SARSA
TD control that updates Q(S, A) toward R + γQ(S′, A′), using the action A′ the agent actually takes next.
Not written yet · 5. Reinforcement learning · SARSA: learning to act
search tree
A tree of positions reachable from the current one, with moves as branches.
Not written yet · 5. Reinforcement learning · Planning by search: MCTS
semi-gradient
A TD update that treats the target as a fixed number, taking the gradient only through the current estimate.
Not written yet · 5. Reinforcement learning · Values from features
semi-Markov decision process
An MDP whose actions take a varying number of steps, so discounting uses γ^k for an action lasting k steps.
Not written yet · 5. Reinforcement learning · Options: thinking in bigger steps
soft target update
Move the target network a small fraction τ toward the online network after every step.
Not written yet · 5. Reinforcement learning · Continuous actions: DDPG
squashed Gaussian policy
A policy that samples from a normal distribution and passes the sample through tanh, so actions stay in range.
Not written yet · 5. Reinforcement learning · TD3 and SAC
state
What the agent knows about the situation right now, such as which grid cell it is in.
Not written yet · 5. Reinforcement learning · Learning by trial and error
state aggregation
Grouping states and giving each group one shared value.
Not written yet · 5. Reinforcement learning · Values from features
state value
V^π(s): the expected return from state s if you follow policy π from then on.
Not written yet · 5. Reinforcement learning · Values and the Bellman equation
stationarity
The rules don't change over time: the same state and action always give the same chances and rewards.
Not written yet · 5. Reinforcement learning · Markov decision processes
stochastic policy
A policy that picks actions at random with set chances, π(a | s), rather than always the same action.
Not written yet · 5. Reinforcement learning · Markov decision processes
stopping criterion
The rule for when value iteration may stop: when the largest change in a sweep is small enough.
Not written yet · 5. Reinforcement learning · Value iteration
target network
A slowly updated copy of the Q-network, used to compute targets so they don't move every step.
Not written yet · 5. Reinforcement learning · Deep Q-networks
target policy
The policy whose values are being learned, often the greedy one.
Not written yet · 5. Reinforcement learning · Q-learning: learning the best while exploring
target policy smoothing
Add a little clipped noise to the target action, so the critic can't exploit a sharp peak.
Not written yet · 5. Reinforcement learning · TD3 and SAC
TD control
Using TD updates on action values to improve a policy while acting.
Not written yet · 5. Reinforcement learning · SARSA: learning to act
TD error
δ = R + γV(S′) − V(S): how much better or worse the step went than the current estimate expected.
Not written yet · 5. Reinforcement learning · Temporal-difference learning
TD target
The value TD moves toward: the reward plus γ times the current estimate of the next state, R + γV(S′).
Not written yet · 5. Reinforcement learning · Temporal-difference learning
TD(0)
Temporal-difference learning: nudge a value estimate toward the reward plus the estimate of the next state, after every step.
Not written yet · 5. Reinforcement learning · Temporal-difference learning
TD(λ)
TD learning toward the λ-return, done efficiently with eligibility traces. λ = 0 is TD(0) and λ = 1 is Monte Carlo.
Not written yet · 5. Reinforcement learning · n-step returns and TD(λ)
TD3
Twin delayed DDPG: two critics (use the smaller), delayed actor updates and smoothed targets.
Not written yet · 5. Reinforcement learning · TD3 and SAC
temporal abstraction
Planning and learning with actions that last many steps.
Not written yet · 5. Reinforcement learning · Options: thinking in bigger steps
terminal state
A state that ends the episode, such as reaching the goal or falling in the pit.
Not written yet · 5. Reinforcement learning · Learning by trial and error
Thompson sampling
Draw one plausible value for each option from what you believe, then pick the option with the highest draw.
Not written yet · 5. Reinforcement learning · Smarter exploration: UCB and Thompson sampling
trajectory
The sequence of states, actions and rewards seen in one run: S₀, A₀, R₁, S₁, A₁, R₂, …
Not written yet · 5. Reinforcement learning · Learning by trial and error
transition function
T(s, a, s′): the chance of landing in state s′ after taking action a in state s.
Not written yet · 5. Reinforcement learning · Markov decision processes
trust region
A limit on how far one update may move the policy, because the estimates are only trustworthy close to the old one.
Not written yet · 5. Reinforcement learning · PPO: safe policy steps
UCB
Upper confidence bound: pick the option with the highest estimate plus a bonus that shrinks as it gets tried more.
Not written yet · 5. Reinforcement learning · Smarter exploration: UCB and Thompson sampling
UCT
Upper confidence bounds applied to trees: MCTS picks moves inside the tree with a UCB score.
Not written yet · 5. Reinforcement learning · Planning by search: MCTS
value iteration
Apply the Bellman optimality update to every state, again and again, until the values stop changing.
Not written yet · 5. Reinforcement learning · Value iteration
vectorised environments
Several copies of an environment stepped together, so one batch of actions gives one batch of transitions.
Not written yet · 5. Reinforcement learning · Actor–critic
α-vectors
The lines (or planes) whose upper edge is the POMDP value function over beliefs, one per conditional plan.
Not written yet · 5. Reinforcement learning · When you can't see the state: POMDPs
ε-greedy
Act greedily most of the time, but with chance ε pick an action uniformly at random.
Not written yet · 5. Reinforcement learning · Bandits: explore or exploit
λ-return
A weighted average of all n-step returns, with weights (1 − λ)λ^(n−1).
Not written yet · 5. Reinforcement learning · n-step returns and TD(λ)

Optimisation

Adam
An optimiser that keeps two running averages per weight, of the gradient (m) and of the squared gradient (v), and steps by α·m̂/√v̂. Each weight gets its own step size, about α.
4. Neural-net foundations · Better steps: momentum and Adam
AdamW
Adam with decoupled weight decay: shrink every weight by the fraction α·λ directly, then take the usual Adam step. Every weight decays at the same rate, whatever its gradient's size.
4. Neural-net foundations · Keeping networks general
gradient ascent
Gradient descent turned around: step along the gradient to make a quantity bigger.
Not written yet · 5. Reinforcement learning · Policy gradients: REINFORCE
gradient clipping
If the gradient's total length is above a limit, scale it down to that limit before the step. The direction stays the same; only the size is capped.
4. Neural-net foundations · Making deep networks train
gradient descent
Improve parameters by taking small steps in the direction that lowers the loss fastest: against the gradient.
3. ML fundamentals · Gradient descent
learning rate
How big each gradient-descent step is. Too small and training crawls; too big and it overshoots or blows up.
3. ML fundamentals · Gradient descent
learning-rate schedule
A rule for changing the learning rate during training. Common shapes: drop it in steps, or warm it up over the first few epochs and then lower it along a cosine curve.
4. Neural-net foundations · Better steps: momentum and Adam
minibatch
A small random group of training examples used for one gradient step.
3. ML fundamentals · Gradient descent
momentum
Gradient descent with a velocity: each step adds the new gradient to β times the last velocity, then moves by α times the velocity. Steady directions build speed; flip-flopping ones cancel.
4. Neural-net foundations · Better steps: momentum and Adam
stochastic gradient descent
Gradient descent that estimates the gradient from a small random batch of examples instead of all of them.
3. ML fundamentals · Gradient descent
weight decay
Shrink every weight by a small fraction (α·λ) at each step, pulling weights the data doesn't need towards zero. For plain SGD it's the same as L2 regularisation; for Adam it isn't.
4. Neural-net foundations · Keeping networks general

Language

embedding
A learned vector that represents something discrete, like a word. Similar things end up with similar vectors.
Not written yet · 12. Language and sequences · Embeddings
language model
A model that gives a probability to each possible next word (or token), given the words so far.
Not written yet · 12. Language and sequences · Language modelling

Large language models

sampling (decoding)
Generating text by repeatedly drawing the next token from the model's softmax probabilities, often with a temperature.
Not written yet · 15. Large language models · Decoding

PyTorch

**`torch.eye(n)`**
torch.eye(n) makes the n × n identity matrix: 1s on the diagonal, 0s elsewhere. It's float32 unless you pass a dtype.
2. PyTorch primer · Tensors
**`torch.linalg.det(A)`**
torch.linalg.det(A) returns the determinant of a square matrix: how much it scales area or volume. The answer is a tensor with no axes.
2. PyTorch primer · Linear algebra in PyTorch
**`torch.linalg.eig(A)`**
torch.linalg.eig(A) returns a square matrix's eigenvalues and eigenvectors (one per column), always as complex tensors. torch.linalg.eigvals returns only the eigenvalues.
2. PyTorch primer · Linear algebra in PyTorch
**`torch.linalg.eigh(S)`**
torch.linalg.eigh(S) returns the eigenvalues (real, smallest first) and eigenvectors (real, at right angles) of a symmetric matrix. It reads only the lower triangle and doesn't check that S is symmetric.
2. PyTorch primer · Linear algebra in PyTorch
**`torch.linalg.inv(A)`**
torch.linalg.inv(A) returns the inverse of a square matrix. It raises an error if A is singular. To solve A x = b, use torch.linalg.solve instead.
2. PyTorch primer · Linear algebra in PyTorch
**`torch.linalg.matrix_power(T, k)`**
torch.linalg.matrix_power(A, k) returns A multiplied by itself k times. Not the same as A ** k, which raises each entry to the power k.
2. PyTorch primer · Linear algebra in PyTorch
**`torch.linalg.solve(A, b)`**
torch.linalg.solve(A, b) returns the x with A @ x = b, by elimination. It's faster and more accurate than torch.linalg.inv(A) @ b.
2. PyTorch primer · Linear algebra in PyTorch
**`torch.linalg.vector_norm(v)`**
torch.linalg.vector_norm(v) returns a vector's length, the square root of the sum of its squared entries. It needs a float tensor.
2. PyTorch primer · Tensors
`.detach()`
t.detach() returns the same numbers with no grad_fn, so autograd treats them as a constant and no gradient flows back through them.
2. PyTorch primer · Autograd: derivatives in PyTorch
`clip_grad_norm_`
torch.nn.utils.clip_grad_norm_(params, max_norm) scales all gradients together so their total length is at most max_norm, in place, and returns the length before clipping. Call it between backward() and step().
4. Neural-net foundations · Making deep networks train
`Dataset` and a `DataLoader`
A Dataset returns one example by index; a DataLoader shuffles a Dataset and serves it in minibatches.
4. Neural-net foundations · The training loop, properly
`F.cross_entropy(scores, target)`
F.cross_entropy(scores, target): log-softmax plus cross-entropy in one safe step. It takes raw scores (logits) with classes on dim 1, and targets as class indices (int64) or as probabilities of the same shape as the scores. It averages over the batch by default.
2. PyTorch primer · Numbers and stability
`F.kl_div(input, target)`
F.kl_div(input, target, reduction='batchmean') computes KL(target ‖ input). input is the model's log-probabilities, target is plain probabilities, and both need a batch axis first.
2. PyTorch primer · Numbers and stability
`F.mse_loss(pred, target)`
torch.nn.functional.mse_loss(pred, target) returns the mean squared error between two tensors of the same shape.
3. ML fundamentals · Gradient descent
`grad_fn`
A tensor's link to the recorded step that made it (e.g. PowBackward0). Following grad_fn.next_functions walks autograd's computational graph back to the leaves.
2. PyTorch primer · Autograd: derivatives in PyTorch
`model.parameters()`
Every learnable tensor inside a module, found automatically. named_parameters() gives their names too.
4. Neural-net foundations · Feedforward networks
`nn.BCEWithLogitsLoss`
Sigmoid plus binary cross-entropy in one numerically safe step. It takes raw scores (logits), not probabilities.
3. ML fundamentals · Logistic regression and classification
`nn.Conv2d`
PyTorch's 2D convolution layer. Input shape (batch, channels, height, width); its weight holds one filter per output channel.
4. Neural-net foundations · Grids and images: convolutions
`nn.Embedding`
A lookup table layer: give it integer ids, get back their learned vectors.
4. Neural-net foundations · Embeddings and autoencoders
`nn.Linear`
PyTorch's linear layer, nn.Linear(in_features, out_features). Its weight has shape (out_features, in_features), one row per output, so it computes x @ weight.T + bias.
2. PyTorch primer · Shapes and broadcasting
`nn.Module`
The base class for every PyTorch model: set up layers in __init__, compute the output in forward.
4. Neural-net foundations · Feedforward networks
`nn.Sequential`
A container that runs layers one after another, feeding each output into the next.
4. Neural-net foundations · From logistic regression to a neuron
`state_dict()`
A dictionary from each parameter's name to its tensor, for a model or an optimizer. Save it to keep or resume training; load it into a model of the same shape to restore.
4. Neural-net foundations · The training loop, properly
`torch.autograd.grad`
torch.autograd.grad(output, inputs) returns the gradients of output with respect to inputs as a tuple, without touching .grad.
2. PyTorch primer · Autograd: derivatives in PyTorch
`torch.distributions`
PyTorch's module of probability distributions, such as Categorical, Normal and Uniform. Each object has .sample() to draw values and .log_prob() to score them, plus batch_shape for holding many distributions at once.
2. PyTorch primer · Randomness and distributions
`torch.finfo(dtype)`
torch.finfo(dtype) reports a float type's limits: eps (the gap after 1), max (the largest number before inf) and tiny (the smallest full-precision positive number).
2. PyTorch primer · Numbers and stability
`torch.Generator`
torch.Generator().manual_seed(n) is a private random stream with its own seed. Pass generator=g to rand, randn, randint, multinomial and similar calls to draw from it instead of the global stream.
2. PyTorch primer · Randomness and distributions
`torch.inference_mode()`
with torch.inference_mode(): (or as a decorator) turns off gradient tracking for code that only predicts. Faster and stricter than no_grad.
4. Neural-net foundations · The training loop, properly
`torch.manual_seed(n)`
torch.manual_seed(n) restarts PyTorch's global random stream from seed n, so every run draws the same random numbers. Call it once at the top of an experiment you want to repeat.
2. PyTorch primer · Randomness and distributions
`torch.nn.functional`
PyTorch's module of plain functions (F.relu, F.cross_entropy). Layer objects like nn.ReLU wrap the same maths.
4. Neural-net foundations · From logistic regression to a neuron
`torch.no_grad()`
with torch.no_grad(): turns off autograd's recording. Use it for weight updates and for checks that need no gradient.
2. PyTorch primer · Autograd: derivatives in PyTorch
`torch.softmax(z, dim=-1)`
torch.softmax(z, dim=-1) turns scores into probabilities along one axis; torch.log_softmax(z, dim=-1) gives their logs directly, as z − logsumexp(z). Both subtract the biggest score first, so they don't overflow.
2. PyTorch primer · Numbers and stability
autograd
PyTorch's automatic differentiation. Mark a tensor with requires_grad=True, compute a single number from it, call .backward(), and the exact derivative appears in the tensor's .grad.
2. PyTorch primer · Autograd: derivatives in PyTorch
broadcasting
How PyTorch combines tensors of different shapes entry by entry: line the shapes up from the right; each pair of sizes must match or one must be 1, and a size of 1 is reused to fit. Missing sizes count as 1. The inputs aren't copied.
2. PyTorch primer · Shapes and broadcasting
device
Where tensors live and where their maths runs: the CPU, an NVIDIA GPU (cuda) or an Apple GPU (mps). A model and its data must be on the same one; .to(device) moves them.
4. Neural-net foundations · The training loop, properly
gradient accumulation
Each .backward() call adds its gradient into .grad instead of replacing it. Useful for combining gradients from several batches; clear .grad (w.grad = None) before each new gradient.
2. PyTorch primer · Autograd: derivatives in PyTorch
max and argmax along a dimension
tensor.max(dim=d) returns the largest values and their indices along d; argmax returns only the indices.
Not written yet · 5. Reinforcement learning · Action values and the best policy
optimiser
An object that updates parameters from their gradients. Each step: optimizer.zero_grad(), loss.backward(), optimizer.step().
3. ML fundamentals · Gradient descent
rsample
A distribution's reparameterised sample in torch.distributions: gradients flow back through it to the parameters.
Not written yet · 5. Reinforcement learning · TD3 and SAC
tensor
PyTorch's array type: a grid of numbers with a shape (how many entries along each axis) and a dtype (what kind of number). A vector is a tensor with one axis, a matrix one with two.
2. PyTorch primer · Tensors
torch.gather
Picks one entry per row from a tensor using a tensor of indices, such as Q(s, a) for the actions taken.
Not written yet · 5. Reinforcement learning · Deep Q-networks
torch.lerp
Linear interpolation: lerp_(end, w) moves a tensor a fraction w of the way toward end, in place.
Not written yet · 5. Reinforcement learning · Continuous actions: DDPG

scikit-learn

`cross_val_score` and `GridSearchCV`
scikit-learn's cross_val_score (k-fold scores for one model) and GridSearchCV (try every setting in a grid with cross-validation, then refit the best).
3. ML fundamentals · Regularisation and cross-validation
`Pipeline` and `ColumnTransformer`
scikit-learn's tools for chaining preprocessing and a model, and for treating different columns differently.
3. ML fundamentals · Features, leakage and the workflow
`train_test_split`
scikit-learn's function that shuffles examples and splits them into two parts, such as training and test.
3. ML fundamentals · Generalisation and overfitting
estimator
scikit-learn's common interface: make a model object, call .fit(X, y) to train it, then .predict(X) to use it.
3. ML fundamentals · Linear regression