Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

AI the lesson

Vectors, Dot Products and Matrix Multiply a show in 8 chapters

Goal: score one film for 3 viewers, using only multiply and add

1 of 8 Your guess

Before we start

Voice search, chat assistants and image search all run on programs called neural networks. Google built a whole chip just to run them.

Which picture is closest to what that chip spends its day doing?

Pick the closest. You find out which fits at the end.

voice search,3 minutesa day eachdatacenters in 2013needed on top, on ordinary chipstwice the buildings4 drawn here, doubled to 8

2 of 8 The problem

2013: a chip built for one sum

In 2013, engineers at Google did a sum on the back of an envelope and did not like the answer. Their speech recognition ran on neural networks, and it worked.

So they asked: what if people used voice search for three minutes a day? On the ordinary chips in every server, Google's datacenters would have to double to keep up.

Those ordinary chips can do anything, so they do any one thing only so fast. A doubling was not free.

Step 1 of 3

heistthe filmaction4romance1comedy351

3 of 8 The idea

A film as a short list of numbers

A computer cannot watch a film. It eats numbers only. So describe the film with numbers.

Pick three things, always in the same order: how much action, how much romance, how much comedy, each out of 5. A heist film might score 4, 1 and 3.

These films and scores are made up for this lesson, so the sums fit in your head.

Step 1 of 3

actionromancecomedyyouyour taste2worth 2a point−1costs 1you get bored1worth 1a pointthe same order as the film

4 of 8 Try it

Multiply the pairs, add them up

Now you. Say one point of action is worth 2 to you, one point of romance costs you 1 (you get bored), and one point of comedy is worth 1.

Your taste is a vector too, in the same order as the film: 2, −1, 1.

Step 1 of 4

actionromancecomedyyou2−11romantic−130comic002← a row:one taste↑ a column: one slot,romance, for every viewer3 rows × 3 columns = 9 numbers

5 of 8 The idea

A table of viewers

One viewer is not a cinema. Add two more, each a taste: the romantic (−1, 3, 0) and the comic (0, 0, 2). Stack all three tastes in one table.

Each viewer is one row, running across. Each slot is one column, running down. A table of numbers in rows and columns is a matrix.

Step 1 of 3

youromanticcomicscores+ mood=10−16−40110 − 46−1 + 0−16 + 17you: −4, a long day · romantic: 0 · comic: +1

6 of 8 The idea

One layer of a neural network

Two small additions turn this into one step of a neural network. First: some viewers are harder to please before the film even starts.

Give each one a fixed amount added to their score: you start at −4 (a long day), the romantic at 0, the comic at +1. That fixed extra per row is the bias.

Step 1 of 5

7 of 8 Your guess

Your picture now

Goal met: one film, 3 viewers, 9 multiply-and-adds. The scores 10, −1, 6, plus moods, then the zero rule, came out 6, 0, 7. Which picture is closest now?

Pick one.

Vectors and matrix multiplyMultiply the pairs, add them up. A neural network does little else.123A vectoraction4romance1comedy3A list where each slotalways means one thing.the heist: 3 slots, 3 dimensionsA dot product4132−118−13pairs multiply, then add:8 − 1 + 3 = 10A layerOne dot product per rowof the table (a matrix):10, −1, 6+ mood −4, 0, 1, thenbelow zero becomes zero:607chalkbrain.com
Vectors and matrixmultiplyMultiply the pairs, add them up.1A vectoraction4romance1comedy3Each slot always means one thing.2A dot product4132−118−138 − 1 + 3 = 103A layerOne dot product per row, + mood,then below zero becomes zero:607chalkbrain.com

8 of 8 Keep this

Keep this

A vector is a list where each slot always means one thing. A dot product multiplies two of them slot by slot and adds up: how much they agree.

A matrix is a stack of them, one per row. Times a vector, it is one dot product per row. Add a bias, apply a rule like ReLU, and that is one layer of a neural network.

Next in the lesson: why a bigger film is not a more similar one, and where this sum turns up again in embeddings and attention.

Read the full lesson