Skip to main content

Notation

The single notation used across every course of Applied AI Mastery: vectors, matrices, probability, learning and reinforcement learning, with the macro that writes each symbol.

One notation runs through every course, so a symbol learned in linear algebra still means the same thing in reinforcement learning. Lessons write symbols with the macros below, and tools/check_lessons.py rejects ad-hoc alternatives.

Where the field has a strong convention we follow it: Sutton and Barto for reinforcement learning, and the common usage of Mathematics for Machine Learning and Understanding Deep Learning for linear algebra and learning.

General

Meaning Symbol Write Notes
Scalar \(a, b, c, x\) a Lower-case italic
Vector \(\vect{v}, \vect{x}\) \vect{v} Lower-case bold. A column unless stated
Matrix \(\mat{A}, \mat{W}\) \mat{A} Upper-case bold
Entry of a vector \(v_i\) v_i Italic, not bold. Indices start at 1 in maths, 0 in code
Entry of a matrix \(a_{ij}\) a_{ij} Row \(i\), column \(j\)
Real numbers \(\R\), \(\R^n\) \R, \R^n
Transpose \(\mat{A}\T\) \mat{A}\T
Norm \(\norm{\vect{v}}\) \norm{\vect{v}} Euclidean unless subscripted
Absolute value \(\abs{x}\) \abs{x}
Standard basis of the plane \(\ihat, \jhat\) \ihat, \jhat \(\ihat = (1, 0)\), \(\jhat = (0, 1)\)
Standard basis of \(\R^n\) \(\vect{e}_1, \dots, \vect{e}_n\) \vect{e}_i
A map from \(A\) to \(B\) \(T : A \to B\) T : A \to B
Partial derivative \(\pd{L}{w}\) \pd{L}{w}
Gradient \(\nabla L\) \nabla L A vector with the shape of its argument
Arg max, arg min \(\argmax_a\), \(\argmin_w\) \argmax_a

In running text a vector may be written as a tuple, \((x, y)\). In displayed equations that involve matrices it is written as a column.

Complex numbers

Meaning Symbol Notes
The imaginary unit \(i\) \(i^2 = -1\). Code writes it 1j
A complex number \(z = a + bi\) A second one is \(u\), because \(w\) is a weight
Real and imaginary parts \(\operatorname{Re} z\), \(\operatorname{Im} z\)
Modulus and argument \(\abs{z}\), \(\arg z\) Length and angle of \(z\) in the plane
Conjugate \(z^*\) Not an overbar, which is kept for means

Probability

Meaning Symbol Write
Probability of an event \(\Prob(A)\) \Prob(A)
Expectation \(\E[X]\) \E[X]
Expectation under a policy or distribution \(\E_\pi[\,\cdot\,]\) \E_\pi[...]
Random variable \(X, S_t, R_t\) Upper-case italic
A value it takes \(x, s, r\) Lower-case italic
Conditional probability \(p(y \mid x)\) p(y \mid x)

Learning

Meaning Symbol Notes
Number of examples \(n\)
Example \(i\) \((x_i, y_i)\) Input and target. The target is also called the label, above all in classification
Number of features \(d\) An input with several features is a vector \(\vect{x}\) in \(\R^d\)
Prediction \(\hat{y}_i\)
Weight, bias \(w\), \(b\) \(\vect{w}\) when there are several weights
All the parameters of a model \(\theta\) Used when a statement holds for any model, whatever its parameters are
Decision threshold \(c\) Predict the positive class when the score is at least \(c\). A lesson that uses “above \(c\)” says so: the two differ only at a tie
Threshold on a probability \(\tau\) Greek tau. Predict the positive class when the predicted probability is at least \(\tau\). For logistic regression this is the cut \(c = \ln\frac{\tau}{1 - \tau}\) on the score. Not used for anything else
Loss \(L\) \(L(w, b)\) as a function of the parameters
Learning rate \(\eta\) Greek eta. Code calls it lr
Step counter \(t\) \(w_t\) is the weight after \(t\) updates
Mini-batch \(B\) A set of example indices, of size \(\abs{B}\)

Reinforcement learning

Following Sutton and Barto, second edition.

Meaning Symbol Notes
State, action, reward at time \(t\) \(S_t, A_t, R_t\) \(R_{t+1}\) is the reward that follows \(A_t\)
Values they take \(s, a, r, s'\) \(s'\) is the next state
Dynamics \(p(s', r \mid s, a)\) Probability of next state and reward
Policy \(\pi(a \mid s)\) Probability of action \(a\) in state \(s\)
Discount rate \(\gamma\) \(0 \le \gamma \le 1\)
Return \(G_t\) \(R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} + \cdots\)
State-value function \(v_\pi(s)\) Expected return from \(s\) under \(\pi\)
Action-value function \(q_\pi(s, a)\) Expected return after taking \(a\) in \(s\), then following \(\pi\)
Optimal values \(v_*(s)\), \(q_*(s, a)\)
An estimate \(V(s)\), \(Q(s, a)\) Upper-case for a table being learned
Bellman operators \(T_\pi\), \(T_*\) \((T_\pi v)(s)\) is one backup of the table \(v\) under \(\pi\); \(T_*\) takes the best action
Max norm \(\norm{v}_\infty\) The largest absolute entry of a value table
Transition matrix and reward vector under a policy \(\mat{P}_\pi\), \(\vect{r}_\pi\) So that \(\vect{v}_\pi = \vect{r}_\pi + \gamma \mat{P}_\pi \vect{v}_\pi\)

Colour in equations

A colour means the same thing in an equation as in a figure. Use it sparingly, to tie a term to the part of the picture it describes.

Role Write Shows as
Data and inputs \cdata{x} \(\cdata{x}\)
Model output \cmodel{\hat{y}} \(\cmodel{\hat{y}}\)
Ground truth \ctruth{y} \(\ctruth{y}\)
Gradients and updates \cgrad{\nabla L} \(\cgrad{\nabla L}\)
Loss and error \closs{L} \(\closs{L}\)
Parameters \cparam{w} \(\cparam{w}\)
Second class \csecond{x'} \(\csecond{x'}\)

In a sentence, the matching spans are [the data]{.c-data}, [the prediction]{.c-model} and so on.

The macros live in site/macros.html. To add a symbol, add it there and to this page in the same change.

Back to top