Module 5 — Matrices & Transformations
A single data point is a vector; a whole dataset is a grid of numbers — a matrix. But matrices are also verbs: multiplying by one transforms data — rotating, scaling, mixing features. Every layer of a neural network is exactly one such transformation. This module makes matrix multiplication concrete and shows why it is the neural-network layer.
A matrix is a grid — of data, or of a transformation
A matrix is a rectangle of numbers with rows and columns. Two readings:
- As data: each row is one example, each column one feature. Five houses with three features each is a 5×3 matrix.
- As a transformation: a matrix can act on a vector and return a new vector — stretching, rotating, or projecting it. This is the reading that powers models.
Matrix × vector: a stack of dot products
To multiply a matrix by a vector, take the dot product of each row with the vector (the move you built in Module 4). Each row produces one number; stack them and you get the output vector:
The visualizer below lets you set the matrix and watch what it does to a vector — and to a whole grid of points. Try the rotation, scale, and shear presets to see the transformation.
This activity needs JavaScript. The lesson below still covers everything.
Matrix × matrix: chaining transformations
Multiplying two matrices means applying one transformation after another. The entry in row \( i \), column \( j \) of the result is the dot product of row \( i \) of the first with column \( j \) of the second. The inner dimensions must match — an \( m\times n \) times an \( n\times p \) gives an \( m\times p \). Build one entry at a time below and watch the row-meets-column pattern.
This activity needs JavaScript.
Two special matrices: identity and transpose
- The identity \( I \) has 1s on the diagonal and 0s elsewhere; multiplying by it changes nothing — the "1" of matrix multiplication.
- The transpose \( A^{\top} \) flips rows into columns. It shows up constantly when lining up dimensions so a multiply is legal.
Trace the multiply
Predict entries and dimensions of matrix products. You'll get a score.
This activity needs JavaScript.