Quick recap
The key takeaways of every lesson on one page. Read it in ten minutes to refresh the whole track; open a lesson when a point feels unclear.
01 How to learn here
- Recognition (it looks familiar) is not recall (you can produce it). Re-reading trains recognition and creates an illusion of fluency.
- Retrieval practice (answering from memory) and spacing (study spread over days) are the two study methods with the strongest evidence (Dunlosky et al., 2013).
- Pretesting (guess before you learn), interleaving (mix problem types) and desirable difficulties (effortful but successful recall) also improve long-term memory.
- Simplified forgetting model: ; a review that succeeds multiplies the stability by more when recall was harder; a review that fails starts over.
- This site's scheduler (an SM-2 variant): a card rated Good every time returns after 1, 3, 8, 20, 50, 125 days; Again brings it back in 10 minutes and restarts it at 1 day with a lower ease.
- The review deck lives only in your browser; save it to a file to move it or keep a copy.
- An active quick look: cover the summary, recall, then compare. Daily: review first (10–15 minutes), then new material.
02 Reading math notation
- A set has no order and no repeats. : element; : subset; (or), (and), (without); : size; = "all real such that ".
- gives each input exactly one output. The range is the set of outputs that occur. : acts first. : input , parameters .
- : rows (samples), columns (features). is Python
X[i-1, j-1]. is sample , not a power. - is a loop that adds the terms. Rules: ; ; , but in general.
- . The empty sum is 0 and the empty product is 1; for .
- is a value; is the set of places where it is reached (it can have several elements). Training: .
- Context decides the meaning of a symbol: (standard deviation or sigmoid), (sum or covariance matrix), (regularization or eigenvalue), (absolute value or set size).
03 Python and NumPy for math
- A NumPy array has a
shape(the length of each axis), adtypeandndim. is shape(n,); is shape(m, n); math index isx[i-1]. - Slices
a[i:j]excludej; negative indices count from the end. An integer index removes an axis, a slice keeps it. Slices are views that share memory; masks return copies; use.copy()to be safe. - A reduction with
axis=kremoves axisk((m, n)→(n,)foraxis=0);keepdims=Truekeeps it with length 1. - Broadcasting: align shapes on the right; sizes must be equal or one of them 1 (missing counts as 1); size-1 dimensions are stretched.
(n,)with(n, 1)silently gives(n, n). *is elementwise;@is the matrix product,(m, p) @ (p, n)→(m, n); for 1-D arraysx @ yis the dot product .np.arange(a, b, step)excludesb;np.linspace(a, b, n)includesband givesnpoints.rng = np.random.default_rng(seed)makes random numbers reproducible: the same seed gives the same sequence.- Floats are not exact: compare with
np.isclose/np.allclose;np.expoverflows toinfabove about 709.78.
04 Lines, powers, exp and log
- The line through and has slope and intercept ; in ML, has weight and bias .
- moves the graph of right by and up by , stretches it vertically by and squeezes it horizontally by .
- Power rules: , , , ; for the exponential, and for every .
- is the power with ; it is defined only for . In ML, means the natural log (base ).
- Log rules: , , . But .
- is strictly increasing, so ; and avoids underflow.
- Exponential data are straight on a semilog plot (slope ); a power law is straight on a log-log plot with slope .
- Every exponential with eventually beats every power ; passes only at .
05 Sigmoid, softmax, log-sum-exp
- The sigmoid maps a real score to , with and .
- The inverse of the sigmoid is the logit, (the log-odds); the slope is , and it is tiny for large (saturation).
- gives positive entries that sum to 1 and keeps the order of the logits.
- Softmax is shift invariant: ; with two classes, .
- Temperature: tends to a one-hot vector at the argmax as and to the uniform vector as .
- satisfies , and .
- The cross-entropy loss from logits is .
- Stable code subtracts : ; in float64, overflows above about 709.78 (float32: 88.72).
06 A gentle tour of vectors
- A vector is a list of numbers. In 2-D and 3-D it is also an arrow from the origin; in higher dimensions we compute with the list.
- Addition and scalar multiplication work entry by entry. As arrows, addition is tip to tail, and goes from the tip of to the tip of .
- The norm is (Pythagoras). is the unit vector in the direction of , and is the distance.
- The dot product is . Its sign tells an acute (+), right (0) or obtuse (−) angle; .
- . With the law of cosines, this proves the geometric formula of the dot product.
- Cosine similarity compares directions and ignores length. For unit vectors, , so distance and cosine give the same ranking.
- A linear model is a dot product: each weight is the change of per unit of feature .
07 Slope, derivative, gradient
- The average rate of change is the slope of a secant line. The derivative is its limit as , the slope of the tangent line.
- Local linear approximation: ; for smooth the error shrinks like . Example: .
- Rules: , , , derivatives of sums and constant multiples, and the chain rule , which gives .
- At a smooth inner minimum or maximum, ; the converse is false ( at 0).
- The central difference has error of order , the forward difference of order ; too small an adds round-off error, so use (central).
- A partial derivative changes and holds the other inputs fixed. The gradient collects them into a vector in the input space.
- : the gradient is the direction of steepest ascent with slope , is steepest descent, and is perpendicular to the contour lines.
- Gradient descent on multiplies by each step: it converges for , zig-zags for , and diverges for .
08 Chance and data
- Probability is long-run relative frequency. The frequency of an event in independent trials has typical error : it shrinks like .
- Rules: ; ; only for independent events.
- Mean (balance point); variance ; standard deviation = its square root, in the unit of the data. The median is robust to outliers; the mean and std are not.
- Sample variance divides by and is unbiased. NumPy uses (
ddof=0) by default, pandas uses (ddof=1). - If , then and . For independent variables, variances add, so the mean of has std .
- A density histogram has bar areas that add up to 1. For a continuous variable, probability = area under the density; a density value can be larger than 1.
- Normal : z-score ; within std: .
- CLT: the mean of independent, identically distributed variables with finite variance is approximately for large . It says nothing about the data being normal.
09 Reading and writing proofs
- A theorem says: if the assumptions hold, then the conclusion holds. A proof is a chain of steps, each justified by a definition, an assumption or an earlier result.
- is false only when is true and is false. Its contrapositive is equivalent; its converse is a different claim. "Iff" needs both directions.
- and . The order of and matters.
- Direct proof: from the assumptions to the conclusion. Contrapositive: from "not " to "not ". Contradiction: assume the claim is false and derive something impossible.
- Induction: prove the base case and the step for every . Both are needed; the step alone proves nothing.
- One counterexample disproves a "for all" claim. Any number of checked examples does not prove it.
- Useful results proved here: is irrational; ; for ; the mean minimizes ; one linear threshold unit cannot compute XOR.