Before this lesson: school algebra (solve 2x+3=7).Lesson 01
is optional. Time: about 55 minutes, plus the notebook. This lesson has many symbols: do not try to
learn the tables at once. Add the recall cards to your review; they bring the symbols back over the
next weeks.
Here is the mean squared error of a linear model, as it appears in many books and papers:
L(w,b)=m1i=1∑m(w⊤x(i)+b−y(i))2.
To read it you need sums (∑), indices (x(i),y(i)), vectors and the transpose
(w⊤x), functions of parameters (L(w,b)) and the idea of a mean (m1∑). All later
tracks write their ideas this way: the gradient in Calculus, the likelihood in
Probability and Statistics, attention in
Linear Algebra lesson 15. Notation is the entry ticket.
The good news: the set of symbols is small, and every symbol is a short sentence in plain words.
Take the prediction of a linear model, y^=w⊤x+b. Read it in three passes.
Say it aloud: "y hat equals w transpose x plus b".
Find the roles. The inputx changes from example to example. The parametersw and
b are fixed while we make a prediction (training chooses them). The outputy^ is what we
compute. The hat says "an estimate".
Check the shapes. If x has n entries, w must have n entries too, and w⊤x is one
number. So y^ is one number.
When a formula looks hard, do these three passes, then compute it for a tiny case (two or three
numbers). The figures below do this for the most common symbols.
The capital Greek letter Σ (sigma) means "add up". In ∑i=1nai:
i is the index (the loop variable). It starts at the lower bound 1 (below Σ) and
goes up by 1 to the upper boundn (above Σ);
ai is the term: for each value of i, compute it and add it to the total.
For example,
i=1∑4i2=12+22+32+42=1+4+9+16=30.
In Python it is a for loop with a running total.
Interactive figure: loading…
Guess the total, then press Step. Each step gives the index its next value, computes the term,
and adds it to the running total; the yellow bar is the
term just added. Try all five sums. For "mean", the sum is divided by m at the end. For the double
sum, watch each row: row i adds up to ai⋅(b1+b2+b3).
Quick check
What is ∑i=13(2i+1)?
Why.
Put i=1,2,3 into the term: (2⋅1+1)+(2⋅2+1)+(2⋅3+1)=3+5+7=15. The answer 13 comes from adding the +1 only once, 2(1+2+3)+1; but the +1 is part of every term, so it is added three times: 2⋅6+3=15.
Data in ML is a table. Each row is one example (a sample), for example one house. Each
column is one feature, for example the area. With m samples and n features the table is
an m×nmatrixX.
Xij is the entry in row i and column j: feature j of sample i. Rows come first.
x(i) is sample i: the whole row i, a list (vector) of n numbers. The superscript in
parentheses is a label, not a power.
xj(i) is entry j of sample i, the same number as Xij.
Math counts from 1. Python counts from 0. So Xij is X[i-1, j-1] in NumPy
(lesson 03 explains the syntax).
Interactive figure: loading…
Click a number, a row header or a column header. The readout gives the math name with indices
from 1 and the Python index from 0. Rows are samples (blue tint), columns are
features (orange tint), and the selection is yellow.
Quick check
In the table of the figure, what is x2(4)?
Why.
x(4) is sample 4, the row (85,3,18), and the subscript 2 picks its second entry: 3 rooms. The answer 2 is entry 2 of row 2, not of row 4. The answer 45 uses the numbers as Python indices: X[4, 2] is row 5, column 3. The answer 85 takes the first entry of the row.
For a function f on an interval, maxxf(x) is the largest value of f: a height. The
argmaxxf(x) is the set of inputs where this largest value is reached: places on the
horizontal axis. "Arg" is short for argument, another word for input.
Interactive figure: loading…
Drag the blue point to the top of the graph. The aqua dashed line is the
maximum value (a height); the yellow marks on the horizontal axis are the
argmax (the places). Try "a tie": the maximum is one number, but the argmax has two elements. Try
"max at the end": the largest value is at the end of the interval. Then switch "Find" to min.
Quick check
Let L(θ)=(θ−3)2+1 for all real θ. What are minθL(θ) and argminθL(θ)?
Why.
(θ−3)2≥0, and it is 0 only at θ=3. So L(θ)≥1, with equality only at θ=3. The minimum is the smallest value, 1. The argmin is the place where it is reached, θ=3. Swapping the two is the most common mistake; the answer 0 forgets the +1.
A set is a collection of distinct objects, its elements. Order and repeats do not matter:
{1,2,2,3}={3,1,2}, a set with 3 elements.
Symbol
Read it as
Example
N
the natural numbers
{1,2,3,…} (some books include 0)
Z
the integers
{…,−2,−1,0,1,2,…}
R
the real numbers
−1.5,0,2,π
x∈A
x is an element of A
2∈{1,2,3}
x∈/A
x is not an element of A
5∈/{1,2,3}
A⊆B
A is a subset of B: every element of A is in B
{1,2}⊆{1,2,3}
A∪B
union: in A or in B (or both)
{1,2}∪{2,5}={1,2,5}
A∩B
intersection: in A and in B
{1,2}∩{2,5}={2}
A∖B
difference: in A but not in B
{1,2}∖{2,5}={1}
∅
the empty set
{1}∩{2}=∅
∣A∣
the size (number of elements)
∣{1,2,2,3}∣=3
A×B
Cartesian product: all pairs (a,b)
{1,2}×{0}={(1,0),(2,0)}
Set-builder notation describes a set by a rule: {x∈R:x>0} is read "the set of
all real x such that x>0". The colon (some books use a bar ∣) means "such that".
Intervals are sets of real numbers between two ends. A square bracket includes the end, a round
bracket excludes it: [a,b]={x∈R:a≤x≤b},(a,b]={x∈R:a<x≤b}, and (0,∞)={x∈R:x>0}(∞ is never included).
Rn is the set of all lists of n real numbers, Rn=R×⋯×R.
So (3,−1)∈R2 is a point of the plane, and a house with 3 features is a point of
R3. The complement of A is Ac=U∖A, where U is the set of everything we
talk about (the universe).
Interactive figure: loading…
Pick an operation and find its region. Circle A and circle
B sit in the universe U={1,…,10}; the result is shaded
yellow and listed in set notation. Try "A⊆B": the region
"in A but not in B" is empty. Try "disjoint": A∩B=∅. For the union, check the rule
∣A∪B∣=∣A∣+∣B∣−∣A∩B∣.
The rule in the caption is the inclusion–exclusion rule for two finite sets. Why it is true:∣A∣+∣B∣ counts each element of A∩B twice (once in A, once in B)
and every other element of A∪B once. Subtracting ∣A∩B∣ removes the second
count. ■
A functionf:X→Y assigns to each input x∈Xexactly one output f(x)∈Y.X is the domain (allowed inputs), Y is the codomain (the type of the outputs). The
range (or image) is the set of outputs that really occur: {f(x):x∈X}.
f:R→R,x↦x2 is read "f maps x to x2". Its codomain is
R, but its range is [0,∞), because a square is never negative.
f versus f(x).f is the function (the whole rule); f(x) is one number, the output at x.
A rule that sends one input to two outputs is not a function. "x↦ a number whose square is
x" sends 4 to both 2 and −2; the function x fixes this by choosing the non-negative one.
Several inputs.f:R2→R,f(x1,x2)=x1+2x2 takes two numbers
(one point of the plane) and gives one number.
Parameters after a semicolon.f(x;θ) is a function of the input x whose shape is set by
the parameters θ. A linear model is f(x;w,b)=w⊤x+b. Training changes θ;
prediction changes x.A model is a function.
Composition.(f∘g)(x)=f(g(x)): first apply g, then apply f to the result. Read
f∘g from right to left: the function next to x acts first. In general
f∘g=g∘f. A neural network is a composition of layers:
f(x)=f3(f2(f1(x))), written f3∘f2∘f1.
Inverse. If every y in the range comes from exactly one x, then f has an inverse functionf−1 with f−1(f(x))=x for every x in the domain. For f(x)=2x+1: solve y=2x+1 for x to get
f−1(y)=(y−1)/2. The function x↦x2 on R has no inverse, since 2 and −2
both give 4; on the domain [0,∞) its inverse is y. Note: f−1 is not 1/f.
Interactive figure: loading…
Compare the two orders. The top row is f∘g (first g), the bottom row is g∘f
(first f). The input x is blue, the value between the machines is
aqua, the output is violet. Change x and the pair of
functions; find an input where both orders agree. The last pair is a function and its inverse.
Quick check
Let f(x)=x2 and g(x)=x−3. What is (g∘f)(1)?
Why.
g∘f means "first f, then g": f(1)=1, then g(1)=1−3=−2. The answer 4 is the other order, (f∘g)(1)=f(−2)=4. Read g∘f from right to left.
A vectorx∈Rn is a list of n numbers x1,…,xn (subscripts count the
entries). In this site, as in most ML books, a vector is a column; to save space we write
x=(x1,…,xn) in a line.
The transposex⊤ turns the column into a row. For two vectors of the same length,
w⊤x=w1x1+⋯+wnxn=∑j=1nwjxj, one number (the dot product;
books also write w⋅x or ⟨w,x⟩).
A matrixA∈Rm×n has m rows and n columns. Rows first:Aij is
in row i, column j. In NumPy, A.shape == (m, n) and Aij is A[i-1, j-1].
The data matrixX∈Rm×n has the samples as rows: Xij=xj(i).
The labels (targets) form a vector y=(y(1),…,y(m)).
x(i) is not a power.x(2) is sample 2. A square is written without parentheses, x2,
or, for the square of an entry, (xj(i))2.
Definition. For numbers am,am+1,…,an (with integers m≤n),
i=m∑nai=am+am+1+⋯+an.
If n<m there are no terms, and the empty sum is 0. The index is a dummy variable: the name
does not matter, ∑i=1nai=∑k=1nak, and i has no meaning outside the sum.
A sum over a set is written ∑i∈Sai: one term for each element of S.
Rules. For numbers ai,bi and a constant c (a number that does not depend on i):
Rule
Formula
Small check
constant term
∑i=1nc=nc
∑i=145=20
linearity
∑i=1n(cai+bi)=c∑i=1nai+∑i=1nbi
∑i=13(2i+1)=2⋅6+3=15
splitting
∑i=1nai=∑i=1kai+∑i=k+1nai for 1≤k<n
∑i=14i=3+7
shifting the index
∑i=1nai=∑k=0n−1ak+1 (put k=i−1)
the Python loop for k in range(n)
swapping a double sum
∑i=1m∑j=1naij=∑j=1n∑i=1maij
add a table by rows or by columns
product of sums
∑i=1m∑j=1naibj=(∑i=1mai)(∑j=1nbj)
a=(1,2),b=(1,2,3):18=3⋅6
Proof of linearity. Write the sum out and regroup (finite sums can be reordered):
The constant-term rule is the case ai=1,bi=0:∑c=c⋅n.■
Proof of the product of sums. The factor ai does not depend on j, so linearity (pull out a
constant) gives ∑jaibj=ai∑jbj. Then B=∑jbj does not depend on i, so
∑iaiB=B∑iai. Together:
∑i∑jaibj=∑iaiB=(∑iai)B.■
A warning. The product of sums has all pairs (i,j). The sum ∑iaibi has only the
pairs with i=j. They are different: for a=(1,2),b=(3,4) we get
∑iaibi=3+8=11, but (∑ai)(∑bi)=3⋅7=21.
Two closed forms.∑i=1ni=2n(n+1) and ∑i=1ni2=6n(n+1)(2n+1).
Why 1+2+⋯+n=n(n+1)/2
Call the sum T. Write it forwards and backwards:
T=1+2+⋯+n and T=n+(n−1)+⋯+1.
Add the two lines term by term. Each pair adds to n+1:1+n,2+(n−1), and so on.
There are n pairs, so 2T=n(n+1), and T=n(n+1)/2.■
For n=100:T=5050.Lesson 09 proves the same
formula a second way, by induction; the same method proves the formula for ∑i2. The notebook
checks both formulas for many n.
Sums in ML. The dot product w⊤x=∑j=1nwjxj (one sum over features). The mean
xˉ=m1∑i=1mx(i) (one sum over samples). The mean squared error of
"Why this matters" has a sum over samples, and inside it a dot product, which is a sum over features.
Quick check
Which expression equals ∑i=12∑j=13aibj?
Why.
The double sum has one term for every pair (i,j): six terms a1b1+a1b2+a1b3+a2b1+a2b2+a2b3. Expanding (a1+a2)(b1+b2+b3) gives exactly these six terms. The sums with aibi keep only the pairs with i=j; and a3 does not even exist here. The last answer would be right only if every bj were 2.
∏i=1nai=a1⋅a2⋯an(Π is the capital Greek letter pi). The empty
product is 1. The factorial is n!=∏i=1ni, so 5!=120 and 0!=1.
In ML: the likelihood. If the samples are independent, the probability of the whole data set is the
product of the probabilities of the samples: L(θ)=∏i=1mp(x(i);θ). For a
coin with P(heads)=0.7 and the data heads, heads, tails:
L=0.7⋅0.7⋅0.3=0.147. Products of many small numbers become tiny, so ML works with the
logarithm, which turns the product into a sum:
log∏iai=∑ilogai for positive ai. Here
log0.147=2log0.7+log0.3≈−1.917 (lesson 04
explains the logarithm).
maxx∈Df(x) is the largest value of f on D, if there is one: a number M with
f(x)≤M for every x∈D and f(x0)=M for some x0∈D.min is defined the same way.
argmaxx∈Df(x)={x∈D:f(x)=maxz∈Df(z)} is the set of places where
the maximum is reached. It can have several elements (a tie). When it has one element, books write
x⋆=argmaxxf(x) for that element.
A maximum may not exist. On the open interval (0,1),f(x)=x gets as close to 1 as you like
but never reaches it, so there is no maximum. On a closed interval [a,b], a continuous function
always has a maximum and a minimum (the extreme value theorem); they can be at the ends.
Two patterns appear everywhere in ML:
Training:θ⋆=argminθL(θ), the parameters with the smallest loss.
We want the placeθ⋆ (the model), not the value L(θ⋆).
Prediction: a classifier computes a probability pk for each class k and predicts
y^=argmaxkpk, the class (a place), not the probability (a value).
NumPy's np.argmax returns only the first index of a tie; the math argmax is the whole set.
is proportional to (equal up to a constant factor)
p(θ∣D)∝p(D∣θ)p(θ)
s.t.
such that; in optimization, "subject to"
minxf(x) s.t. x≥0
y^
y hat: an estimate or a prediction
y^=w⊤x+b
xˉ
x bar: a mean
xˉ=5
x⋆
x star: the best (optimal) value
θ⋆=argminθL(θ)
x~
x tilde: a changed or noisy version of x
x~=x+ε
Note that ⇒ goes one way only: x>2⇒x2>4 is true, but x2>4 does not
imply x>2 (take x=−3). The bars ∣⋅∣ have several meanings: ∣−3∣=3
(absolute value), ∣S∣ (size of a set), and in some books ∣A∣ (determinant
of a matrix). The length (norm) of a vector has double bars: ∥x∥.
a step size or learning rate; a significance level in statistics
β
beta
coefficients of a regression; momentum factors β1,β2 in Adam
γ
gamma
the discount factor in reinforcement learning; a scale parameter
δ,Δ
delta
a small number; Δ = a change or difference, Δx=xnew−xold
ε
epsilon
a small positive number; a noise term
η
eta
the learning rate
θ
theta
the parameters of a model
λ
lambda
the strength of a regularization term; an eigenvalue
μ
mu
a mean
ν
nu
degrees of freedom; a second mean or measure
π
pi
the number 3.14159…; a policy in reinforcement learning
ρ
rho
a correlation coefficient
σ,Σ
sigma
σ: standard deviation, or the sigmoid function; Σ: a sum, or a covariance matrix
τ
tau
a temperature; a time constant
ϕ,φ
phi
a feature map; the density of the standard normal distribution
ψ
psi
a second feature map or network
ω,Ω
omega
a frequency; Ω: a set of all outcomes
The same letter can mean different things.σ(z) with an argument is usually the sigmoid
function; σ alone, next to μ, is a standard deviation. Σ with bounds below and above
is a sum; Σ alone, next to μ in a Gaussian, is a covariance matrix. λ is a
regularization strength in a loss and an eigenvalue in linear algebra. The context decides; good
papers define each symbol when it first appears.
Two more symbols: expectation and big-O
Expectation.P(A) is the probability of an event A. For a random number X with finitely
many values, the expectation (mean) is E[X]=∑xxP(X=x), a weighted sum. For a
fair die, E[X]=(1+2+⋯+6)/6=3.5.Lesson 08
introduces these ideas.
Big-O.f(n)=O(g(n)) means: for large n,f(n) is at most a constant times g(n) (there are
C>0 and n0 with ∣f(n)∣≤Cg(n) for all n≥n0). It describes how cost
grows. Adding n numbers costs O(n) operations; multiplying two n×n matrices with the
usual loops costs n3 multiplications, O(n3).3n2+10n=O(n2), because
3n2+10n≤4n2 for n≥10.
Answers to section 1. (1) 3+5+7=15. (2) No: ∑iaibi=1⋅3+2⋅4=11,
but (1+2)(3+4)=21. The product of sums has all four pairs aibj; the first sum has only the
pairs with i=j. (3) No. In ML papers x(2) is sample number 2, a label in parentheses; the
square is x2.
(a) Read and compute a loss. Three houses, two features each, and their prices:
X=120013,y=245,w=(1,1),b=1.
Compute L(w,b)=m1∑i=1m(w⊤x(i)+b−y(i))2.
Shapes.X∈R3×2, so m=3 samples and n=2 features. w has 2
entries, so w⊤x(i) is defined.
Samples.x(1)=(1,0),x(2)=(2,1),x(3)=(0,3). For example x1(2)=X21=2.
Predictionsy^(i)=w⊤x(i)+b=w1x1(i)+w2x2(i)+b:
y^(1)=1⋅1+1⋅0+1=2;
y^(2)=1⋅2+1⋅1+1=4;
y^(3)=1⋅0+1⋅3+1=4.
Errorsy^(i)−y(i):2−2=0,4−4=0,4−5=−1.
Squares:0,0,1.Sum:∑i=13(…)2=1.
Mean:L(w,b)=31⋅1=31≈0.333.
(b) A double sum.a=(1,2),b=(1,2,3). Expand ∑i=12∑j=13aibj row by row:
i=1:a1b1+a1b2+a1b3=1+2+3=6;
i=2:a2b1+a2b2+a2b3=2+4+6=12;
total: 6+12=18, and indeed (1+2)(1+2+3)=3⋅6=18.
(c) max and argmax on a grid. Let L(θ)=(θ−2)2+1 on the grid
θ∈{0,1,2,3,4}. The values are 5,2,1,2,5. So minθL(θ)=1 and
argminθL(θ)={2};maxθL(θ)=5 and argmaxθL(θ)={0,4}
(a tie). Now take L(θ)=(θ−1.5)2 on the same grid: the values are
2.25,0.25,0.25,2.25,6.25, so the minimum is 0.25 and the argmin is {1,2}.
Python counts from 0, so every math index is shifted by one. sum(...) and np.sum play the role of
Σ. (Lesson 03 teaches NumPy properly.)
importnumpyasnpX=np.array([[1,0],[2,1],[0,3]])# 3 samples (rows), 2 features (columns)y=np.array([2,4,5])w=np.array([1,1]);b=1m,n=X.shapeprint(m,n)# 3 2print(X[1,0])# x^(2)_1 = 2 (row 2 -> index 1, column 1 -> index 0)# the loss, written as the two sums of the formulatotal=0foriinrange(m):# sum over samplesy_hat=sum(w[j]*X[i,j]forjinrange(n))+b# w^T x^(i) + b: sum over featurestotal+=(y_hat-y[i])**2print(total/m)# 0.3333333333333333# a double sum equals the product of two sumsa,bb=np.array([1,2]),np.array([1,2,3])print(sum(a[i]*bb[j]foriinrange(2)forjinrange(3)),np.sum(a)*np.sum(bb))# 18 18# argmin on a grid: np.argmin returns only the FIRST index of a tiegrid=np.array([0,1,2,3,4])L=(grid-1.5)**2print(L.min(),grid[np.argmin(L)],grid[L==L.min()])# 0.25 1 [1 2]
Every loss function is a mean over samples: m1∑i=1mℓ(f(x(i);θ),y(i)),
where ℓ is the loss of one sample. Mean squared error for regression, cross-entropy for
classification (Information Theory).
Training is θ⋆=argminθL(θ), found with gradient descent
(Optimization); prediction with a classifier is y^=argmaxkpk.
Maximum likelihood maximizes ∏ip(x(i);θ), in practice the sum
∑ilogp(x(i);θ) (Probability and Statistics).
Neural networks are compositions fL∘⋯∘f1 of layers, each a function with its
own parameters (Deep Learning).
Attention in transformers is written softmax(QK⊤/dk)V:
matrices, a transpose and a function applied row by row. Each entry of QK⊤ is a dot product,
a sum over the dk dimensions: (QK⊤)st=∑k=1dkQskKtk.
ML for science: a simulation grid or a time series is indexed the same way: uij at grid
point (i,j),xt at time step t; numerical schemes are sums over neighbours.
Read aloud and compute: ∣{x∈Z:−2≤x<3}∣.Answer"The number of integers x with −2≤x<3." The set is {−2,−1,0,1,2} (3 is excluded), so the size is 5.
Compute ∑i=14(3i−1) in two ways: term by term, and with the rules.AnswerTerm by term: 2+5+8+11=26. With the rules: 3∑i=14i−∑i=141=3⋅10−4=26.
Let f(x)=2x and g(x)=x+5. Give formulas for f∘g and g∘f.Answer(f∘g)(x)=f(x+5)=2x+10.(g∘f)(x)=g(2x)=2x+5. They differ.
What is the range of f:R→R,f(x)=x2+1? What is argminxf(x)?AnswerThe range is [1,∞), because x2≥0 and every value y≥1 is reached at x=y−1. The minimum value is 1 and the argmin is {0}.
X∈R100×3 is a data matrix. How many samples and features? Write x2(7) as a NumPy expression.Answer100 samples (rows) and 3 features (columns). x2(7)=X72 is `X[6, 1]`.
Compute ∏i=14i+1i.Answer21⋅32⋅43⋅54=2⋅3⋅4⋅51⋅2⋅3⋅4=51. Every factor except the first numerator and the last denominator cancels.
Recall cardsAnswer in your head first, then reveal. Add the cards to your review deck to see them again just before you would forget.
How do you read {x∈R:x>0}, and which interval is it?
"The set of all real numbers x such that x>0." It is the interval (0,∞).
State the linearity rule of sums.
∑i=1n(cai+bi)=c∑i=1nai+∑i=1nbi for a constant c.
What is ∑i=1nc for a constant c?
nc: the constant is added n times.
What does ∑i=1m∑j=1naibj equal, and why?
(∑iai)(∑jbj): pull ai out of the inner sum, then pull the constant ∑jbj out of the outer sum.
Compute ∏i=14i.
1⋅2⋅3⋅4=24=4!.
What is the difference between maxxf(x) and argmaxxf(x)?
The max is the largest value of f (a height). The argmax is the set of inputs where that value is reached (places).
In ML notation, what are x(i) and xj(i)?
x(i) is sample (example) number i, a vector; xj(i) is feature j of that sample. The (i) is a label, not a power.
A∈Rm×n. What is its NumPy shape, and which Python index gives Aij?
A.shape == (m, n)(m rows, n columns); Aij is A[i-1, j-1].
In (f∘g)(x), which function acts first?
g:(f∘g)(x)=f(g(x)). Read from right to left.
Give two meanings of σ in ML texts.
The standard deviation (as in μ,σ), and the sigmoid function σ(z)=1/(1+e−z).
"Write the mean squared error of linear regression." — L(w,b)=m1∑i=1m(w⊤x(i)+b−y(i))2;
in matrix form m1∥Xw+b1−y∥2. Say what m,x(i) and w⊤x are.
"What is the difference between max and argmax? What does np.argmax do with ties?" — The max is a
value, the argmax a set of places; np.argmax returns the first index of a tie.
"Why do we maximize the log-likelihood instead of the likelihood?" — The log turns the product over
samples into a sum, which avoids numbers that underflow to 0 and is easier to differentiate; the log
is increasing, so the argmax does not change (lesson 04).
"What is the shape of XW for X∈Rm×n and W∈Rn×k?" —
m×k. Shape questions are the most common notation questions in coding interviews.
The notebook for this lesson runs in Colab or in your browser. It uses only plain Python,
np.array and np.sum, and every line has a comment. Five short exercises, each with a check cell
and a folded solution:
Write ∑i=1ni2 as a loop and with sum(...), and check the closed form for many n.
Check that ∑i∑jaibj=(∑a)(∑b) and that ∑iaibi is different.
Read entries, samples and features of a data table with 1-based math indices.
Compute union, intersection, difference and complement with Python sets, and check inclusion–exclusion.
Find the maximum and the whole argmax of a function on a grid, including a tie.
How to read the index, the bounds and the term of a Σ-sum, with examples.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
Union and intersection with Venn diagrams, as in the set figure of this lesson.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
Composition as one function feeding into another; watch the order of evaluation.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
The argmin and argmax operators as used in machine learning.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
Goodfellow, Bengio and Courville, Deep Learning, Notation:
the notation page of a standard ML textbook; read it after this lesson and check that you know each line.
Deisenroth, Faisal and Ong, Mathematics for Machine Learning (free
PDF): the table of symbols at the start and the beginning of chapter 2.
Lehman, Leighton and Meyer, Mathematics for Computer Science
(free PDF), chapter 4 (sets, sequences, functions) and chapter 14 on sums.
Andrew Ng and Tengyu Ma, CS229 lecture notes, part I:
the x(i),y(i) notation for training data, used in many ML courses.
Code along in Colab
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.