矩阵乘法 · 每个结果都是一次行列点积Matrix Multiplication · Every Output Is a Row-Column Dot
Product
row · column → one output cell → transformed space
矩阵乘法用前矩阵的行与后矩阵的列做点积,批量完成线性变换。它是神经网络“很多乘加”的最小可视机制。Matrix multiplication takes dot products between rows of the first
matrix and columns of the second, batching a linear transformation. It
is the smallest visible mechanism behind neural-network
multiply-adds.
01 · 一张透明变形板01 · A transparent transformation sheet
怎样用四个数,让整张坐标网格一起拉伸、旋转或翻转?How can four numbers stretch, rotate, or flip an entire coordinate
grid at once?
M×
022×2 线性变换台2×2 Linear Transformation Bench
矩阵拖动型Drag matrix values
行列式Determinant
1.00
ad − bc
输出第 1 格Output cell 1
2.00
y₁
输出第 2 格Output cell 2
1.00
y₂
03一个结果格的 4 个零件Four Parts of One Output Cell
行 × 列Row × column
PART 01
选一行Choose a row
输出 y1 使用 M 的第一行 [a,b]。Output y1 uses the first row [a,b] of M.
PART 02
选一列Choose a column
输入向量 v = [2,1]T 是一列。Input vector v = [2,1]T is one column.
PART 03
对应相乘Multiply pairs
a×2 与 b×1 分别计算,位置不能错配。Compute a×2 and b×1 without crossing positions.
PART 04
相加落格Add into one cell
两个乘积相加,写进输出向量的一个位置。Add the products and write one position in the output
vector.
04最小机制:每格都是一次点积Minimal Mechanism: Every Cell Is a Dot Product
y = Mv
yi = Σk=12 Mikvk
点击上方画布的 y1 或 y2
单格,查看对应矩阵行怎样与同一输入列做点积。Select y1 or y2 on the canvas to see the
corresponding matrix row dot the same input column.
拖动矩阵分量Drag a matrix value一行的权重改变A row's weights change
空间整体变换Space transforms所有点使用同一规则Every point uses the same rule
05边界实验:让内侧维度对不上Boundary Test: Mismatch the Inner Dimensions
主动制造失败Create a failure
拿 2×2 矩阵乘三分量向量Multiply 2×2 by a three-component vector
点击后把输入列从 [2,1] 改成
[2,1,7]。矩阵行只有两个位置,第三个分量找不到配对项。Change the input from [2,1] to [2,1,7]. A matrix row has two
positions, leaving the third component without a partner.
尚未执行。行列点积要求两边配对长度相同。Not run yet. A row-column dot product requires matching inner
lengths.
✗ 任意两个矩阵都能相乘。Any two matrices can be multiplied.
→ ✓ 前者列数必须等于后者行数。The first column count must equal the second row
count.
✗ 矩阵乘法就是同位置逐格相乘。Matrix multiplication is elementwise
multiplication.
→ ✓ 每个结果格来自一整行与一整列的点积。Each output cell comes from a full row-column dot
product.
✗ AB 与 BA 总是相等。AB always equals BA.
→ ✓ 顺序改变会改变配对行列,甚至让形状不合法。Order changes row-column pairing and may invalidate the
shapes.
06 · 一句话带走06 · One line to keep
矩阵乘法用前矩阵的行与后矩阵的列做点积,批量完成线性变换;拖动任一分量,网格和对应输出格都会按同一乘加规则更新。Matrix multiplication dots rows of the first matrix with columns of
the second to batch a linear transformation. Drag any component
and the grid and output cells update by the same multiply-add
rule.