Linear algebra for ML
standardbeginnerA vector is a list of numbers — one training example, or one set of model weights. A matrix is a grid of numbers — a batch of examples, or a layer of weights. A tensor is the general term for either, at any number of dimensions. Every neural network layer is, mechanically, matrix multiplication plus a nonlinearity.
Think of it as
You do not need to compute any of this by hand — libraries do that — but you do need to read the shapes. A vector of length n is a point in n-dimensional space. A dot product of two vectors measures how much they point the same direction, and is the core operation behind similarity search and a single neuron's weighted sum. Matrix multiplication is many dot products at once — a batch of input vectors times a weight matrix produces a batch of outputs in one operation, which is why it is written as one line of code instead of a loop. A norm measures a vector's length (L2 norm is ordinary Euclidean distance from the origin) and shows up constantly — regularization penalizes large weight norms, embeddings are often compared after normalizing to unit length. Transpose flips a matrix's rows and columns; a matrix has an inverse only if it is square and none of its rows are redundant, and 'inverse' is how you undo a linear transformation.
The shapes, at a glance
Remember: A vector is a list of numbers, a matrix is a grid, a tensor is either at any dimension. Matrix multiplication is a batch of dot products in one operation — the mechanical core of every neural network layer.
See also: tensors devices and autograd


