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: 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.

  • Adding a bias gives an affine map:

    xAx+bx \mapsto Ax + b
  • Neural layers use weight matrices to mix input features into output features.

Key Notation

  • AA: matrix AA, a table of numbers.
  • aija_{ij}: read as "a sub i j"; the entry in row ii, column jj.
  • m×nm \times n: read as "mm by nn"; mm rows and nn columns.
  • AxAx: read as "AA times xx"; a matrix-vector product.
  • ABAB: read as "AA times BB"; a matrix product.
  • II: the identity matrix; leaves matching vectors unchanged.
  • DD: a diagonal matrix; scales coordinates separately.
  • ATA^T: read as "AA transpose"; swaps rows and columns.
  • Wx+bWx + b: read as "WxW x plus bb"; an affine step before activation.

Shape Rules

  • For AxAx, if AA is m×nm \times n and xx has length nn, then AxAx has length mm.
  • For ABAB, if AA is m×nm \times n and BB is n×pn \times p, then ABAB has shape m×pm \times p.
  • For XWXW, if XX is examples by features and WW maps features to output coordinates, then XWXW is examples by output coordinates.
  • For ATA^T, if AA is m×nm \times n, then ATA^T is n×mn \times m.
  • For Ax+bAx + b, the vector bb must have the same length as AxAx.

Checks Before You Move On

  1. Reversing row and column order.
  2. Multiplying shapes without checking the middle dimensions.
  3. Treating matrix multiplication as entry-by-entry 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 coordinate.
  10. Treating Ax+bAx + b 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.