M01 / FOUNDATIONS

Tensors are just shaped arrays.
Watch them flow.

A matrix multiplication isn't magic — it's a sequence of dot products. A reshape isn't a transformation — it's a re-indexing. Let's animate the parts you can't see when you write @ in NumPy.

EXPERIMENT 01.01 · MATMUL.LIVE STATUS · REAL-TIME BACKEND · TYPED ARRAY
// 01

Matrix multiplication · A · B = C

A: 3×4 · B: 4×3 · C: 3×3
CONTROLS
M (rows A) 3
K (inner) 4
N (cols B) 3
SPEED 60
CURRENT STEP
row · 0
col · 0
dot-product:
— pending —
Σ  = 0.00
LIVE MULTIPLICATION
Each output cell C[i,j] = the dot product of row i of A and column j of B.
// 02

Linear transformations · vectors under a 2×2 matrix

2×2 MATRIX
determinant · 1.000
trace · 2.000
area scale · ×1.00
R² → R²  ·  basis vectors animate
// 03

Broadcasting · how NumPy implicitly aligns shapes

CASE STUDY · (4, 1) + (1, 5) = (4, 5)
COLUMN VECTOR (4, 1)
+
ROW VECTOR (1, 5)
=
RESULT (4, 5)
Broadcasting rule → NumPy compares shape dims right-to-left. Two dims are compatible if they're equal, or one of them is 1. The "1" dim is virtually stretched. No memory is actually copied — the loop just indexes mod 1.
// 04

The big picture · ND tensor flows in deep learning

CANONICAL SHAPES PYTORCH BCHW
CONTEXTSHAPEEXAMPLEMEANING
image batch(B, C, H, W)(32, 3, 224, 224)32 RGB images at 224²
conv weights(Cout, Cin, kH, kW)(64, 3, 3, 3)64 filters of 3×3 over 3 chans
feature map(B, C, H, W)(32, 64, 56, 56)post-conv activations
sequence(B, T, D)(32, 196, 768)ViT tokens / embedding dim
attention logits(B, H, T, T)(32, 12, 196, 196)heads × token-to-token
classifier logits(B, K)(32, 1000)scores over K classes