Skip to content
mlmentorship

Matrices as linear maps

A matrix is a linear function from one vector space to another. Every operation in ML. Projection, rotation, basis change, gradient flow. Is matrix multiplication.

Published · 4 min read ·Core ·Foundation

Visual quick review

Visual first · depth when needed

Trace how a matrix maps basis vectors to its columns and therefore maps any input by taking the same linear combination of those columns.

Preparing the visual…

Summary

A matrix represents a linear map defined by . Composition of linear maps corresponds to matrix multiplication; the columns of are the images of the standard basis vectors.

Every layer in a neural network is a linear map (followed by a non-linearity). Every embedding lookup, every attention score, every gradient backward pass is a matrix multiplication. Understanding what a matrix does geometrically. Rather than just how to compute with it. Is the foundation for reasoning about model capacity, conditioning, and gradient flow.

The geometry

For :

  • Columns of = images of . Span them and you get the column space (range of the map).
  • Rows of = linear functionals; span the row space.
  • Null space = . Directions the map collapses.
  • Rank = dimension of column space = dimension of row space.

If is square and invertible, is a bijection: it stretches, rotates, and reflects without losing information. If rank , collapses dimensions.

Learning objective

Trace how the columns determine every output, including a direction that collapses to zero.

A rank-one matrix maps basis vectors to its columns and collapses a nonzero input For A with rows one comma two and one comma two, the input basis vectors e one and e two map to columns a one equals one comma one and a two equals two comma two. The input x equals two e one minus e two is nonzero. In the output plane, both columns lie on the range line y equals x, and A x equals two a one minus a two equals zero. Numbered panels, coordinates, arrow directions, and line styles convey the result without relying on color. 1 · Read x in the input basis x = (2, −1) = 2e₁ − e₂ e₁ axis e₂ axis e₁ e₂ x ≠ 0 2 · Use the same weights on A's columns A = [[1, 2], [1, 2]] · Ae₁ = a₁ · Ae₂ = a₂ range(A): y = x a₁ = (1, 1) a₂ = (2, 2) = 2a₁ then subtract a₂ Ax = 2a₁ − a₂ = (0, 0) x is in null(A)
Read it this way: first map each input basis vector to its matching column: Ae1 = a1 and Ae2 = a2. Then keep the input's coefficients. Here x = 2e1e2, so Ax = 2a1a2 = 0. Both columns lie on one line, so the map has rank one and collapses a nonzero direction.

Original coordinate construction checked against MIT 18.022, Peter Selinger's CC BY 4.0 Matrix Theory and Linear Algebra, and Boyd and Vandenberghe's Introduction to Applied Linear Algebra.

Composition and multiplication

If and , then . Matrix multiplication is the composition of linear maps. This is why multiplication is associative () but not commutative (order of operations matters).

Special families

MatrixGeometric action
Orthogonal ()Rotation or reflection (preserves length and angle)
DiagonalIndependent scaling along each axis
SymmetricHas real eigenvalues; orthogonal eigenvector basis
Positive definiteSymmetric + all eigenvalues > 0; defines an inner product
PermutationReorders coordinates
Projection ()Maps onto a subspace, kills orthogonal complement

Common pitfalls

  • Treating matrix multiplication as element-wise. Use Hadamard () for element-wise; matrix multiplication is composition.
  • Forgetting that shapes determine the map. is a map , not the other way around.
  • Confusing column space with row space. Both have dimension = rank, but they live in different spaces ( vs ).