Back to Home

Dimensions

Master shapes, gradients, and broadcasting.

1. Matrix Multiplication Rules

Inner dimensions must match. (n×D) · (D×k) = (n×k). This is the engine of Deep Learning.

Rows (Samples)
[3 × 4]
×
Cols (Features)
[4 × 2]
=
Result
[3 × 2]
Inner Dimensions match (4 == 4) ✅

Row 0 · Col 0 = Output[0, 0]

Matrix Rule

(N×D) · (D×K) = (N×K). The inner dimensions must match and collapse.

Broadcasting

Adding a vector to a matrix? The vector repeats implicitly to match dimensions.

Vectorization

Loops are slow. We operate on the entire batch (N) at once.