Course 2 of 9
Linear Algebra for AI
After this course you can read data, embeddings and network layers as vectors and matrices.
12 lessons, 4 labs and a project. About 1 h 15 min of video.
Start with lesson 1- VectorsA vector is a list of numbers in order: drawn as an arrow it is a move, as a point it places a thing.8 min
- Adding and scaling vectorsScale some vectors and add them up, and everything you can reach is their span: a line, a flat sheet, or more.6 min
- The dot productMultiply two vectors' matching numbers and add them up: its sign says whether they lean the same way, and longer arrows make it bigger.6 min
- Distance and cosine similarityDistance and the dot product care how long arrows are; shrink every arrow to length 1 and you compare only direction: cosine similarity.6 min
- Lab 1Search a store by meaningYou will score your friends' tastes by the dot product, by distance and by cosine similarity, then search a real store's products by meaning, with a model's numbers.35 min
- A matrix is a transformationA matrix moves every point of the plane at once, and its columns say where the arrows one step across and one step up land.7 min
- Matrix multiplicationEach number a matrix gives is one row's dot product with the input, so a layer is one multiplication, and two moves, one after another, are one matrix.7 min
- Rank and low-rank matricesThe rank of a matrix is how many directions it leaves after its move, and a matrix of low rank is a few columns times rows, stored in few numbers.7 min
- Lab 2A small layer, and a cheap change to itYou will move the handwritten zero with a matrix you build from two arrows, work out a small layer by hand and with
@, join two moves into one matrix, and change the layer with a column times a row, the way LoRA does.40 min - ProjectionDrop a vector onto a line at a right angle: with the line's arrow shrunk to length 1, the dot product says how far along it lands, and what is left is the error.7 min
- Eigenvectors and eigenvaluesWhen a matrix moves the plane, most arrows turn; an eigenvector is an arrow it only stretches, and its eigenvalue says how many times.7 min
- Lab 3The penguins' best roadYou will drop the penguins onto a road through their cloud, measure what that one number leaves out, and find the road that leaves the least, as an eigenvector.40 min
- SVD and low-rank approximationEvery matrix is a turn, a stretch and a turn, so it splits into pieces, strongest first; keep the strongest few and you keep most of the matrix in far fewer numbers.6 min
- High-dimensional spaceIn many dimensions, random points sit about as far from each other as they can, and random arrows point at nearly right angles; real data still works because its numbers move together.7 min
- Lab 4Nearest digits, in fewer numbersYou will find every handwritten digit's nearest digit in 64 numbers, see why it works when random points fail, then keep each digit in its strongest directions and find out how few numbers still find the right one.45 min
- ReviewQuestions from the whole course8 questions from 8 lessons, in a mixed order. See what you still remember.
- EndingWhat can you build with linear algebra now?That's the whole course. Here's what you can do now, the project where you compress your own photo with SVD, and the labs to start with.1 min
- ProjectCompress a photo with SVDYou build a notebook that finds a photo's strongest pieces by hand and holds them against NumPy's SVD, keeps the photo in a share of its numbers and measures what was lost, and does the same to a colour photo of your own.2.5 h
