Review
Use these notes to review Chapter 3 quickly.
Core Picture
A matrix is a rectangular table of numbers with row-column structure.
In computation, a matrix often acts as an operation:
input vector
-> matrix
-> output vector
The table shape controls whether the operation is allowed and what shape the output has.
Key Ideas
-
Matrix entries are indexed by row and column.
-
Shape is rows by columns.
-
A matrix-vector product uses one dot product per row.
-
Matrix multiplication repeats the matrix-vector idea across columns.
-
Matrix multiplication is not entry-by-entry multiplication.
-
Matrix multiplication is order-sensitive: and are different questions, and one may be undefined.
-
The identity matrix leaves vectors unchanged.
-
A diagonal matrix scales coordinates separately.
-
The transpose swaps rows and columns.
-
Batches can be stored as matrices of examples by features.
-
A matrix can be read as a linear map.
-
Adding a bias gives an affine map:
-
Neural layers use weight matrices to mix input features into output features.
Key Notation
- : matrix , a table of numbers.
- : read as "a sub i j"; the entry in row , column .
- : read as " by "; rows and columns.
- : read as " times "; a matrix-vector product.
- : read as " times "; a matrix product.
- : the identity matrix; leaves matching vectors unchanged.
- : a diagonal matrix; scales coordinates separately.
- : read as " transpose"; swaps rows and columns.
- : read as " plus "; an affine step before activation.
Shape Rules
- For , if is and has length , then has length .
- For , if is and is , then has shape .
- For , if is examples by features and maps features to output coordinates, then is examples by output coordinates.
- For , if is , then is .
- For , the vector must have the same length as .
Checks Before You Move On
- Reversing row and column order.
- Multiplying shapes without checking the middle dimensions.
- Treating matrix multiplication as entry-by-entry multiplication.
- Forgetting that each output entry comes from a row dot product.
- Confusing input features with output features in a layer.
- Losing the batch dimension when reading neural network shapes.
- Thinking of a matrix only as a table and not as an operation.
- Forgetting to name what each batch axis means before reading a shape.
- Forgetting that each row of a weight matrix produces one output coordinate.
- Treating as a linear map instead of an affine map.
Bridge to Geometry
The next chapter will give these operations a picture.
A matrix can stretch, rotate, shear, or project vectors. Geometry explains what those words mean visually: which directions move, which directions stay aligned, and how transformations change distances, angles, and boundaries.