The Matrix Everybody Writes Down and Nobody Builds
Last timeOne Rule per Operation
The backward step is usually written as a vector meeting a matrix of partial derivatives. That matrix is never built, because only its product with a vector is ever needed.
Write out a backward step in full generality and a matrix appears: every output
of an operation differentiated against every one of its inputs. It is the right
object mathematically and it is never built, and the gap between those two facts
is worth a lesson.
The size of the thing
Take a linear layer of the width used in a mid-sized model.
| width | entries in the matrix | size relative to the sma | |
|---|---|---|---|
| a small layer | 512 | 262144 | 1 |
| a mid-sized layer | 4096 | 16777216 | 64 |
| a large layer | 16384 | 268435456 | 1024 |
The entries are not merely numerous; they are almost all zero for many
operations, and every one of them is consumed a single time. Building the matrix
would be the most expensive way possible to compute something that is then
thrown away.
The lesson stops here
4 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents