Summary and Revision Notes

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 coordinate-wise multiplication.
  • Matrix multiplication is order-sensitive: ABAB and BABA 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.
  • Neural layers use weight matrices to mix input features into output features.

Key Notation

NotationRead asMeaning
AAmatrix Aa table of numbers
aija_{ij}a i jentry in row i, column j
m×nm \times nm by nm rows and n columns
AxAxA times xmatrix-vector product
ABABA times Bmatrix product
IIidentity matrixleaves vectors unchanged
DDdiagonal matrixscales coordinates separately
ATA^TA transposeswaps rows and columns
Wx+bWx + bW x plus blinear layer pre-activation

Shape Rules

ExpressionRequirementOutput
AxAxAA is m×nm \times n, xx has length nnlength mm
ABABAA is m×nm \times n, BB is n×pn \times pm×pm \times p
XWXWXX is batch by features, WW maps features to outputsbatch by outputs
ATA^TAA is m×nm \times nn×mn \times m

Common Mistakes

  1. Reversing row and column order.
  2. Multiplying shapes without checking the middle dimensions.
  3. Treating matrix multiplication as coordinate-wise multiplication.
  4. Forgetting that each output entry comes from a row dot product.
  5. Confusing input features with output features in a layer.
  6. Losing the batch dimension when reading neural network shapes.
  7. Thinking of a matrix only as a table and not as an operation.
  8. Forgetting to name what each batch axis means before reading a shape.
  9. Forgetting that each row of a weight matrix produces one output feature.

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.