Matrices
Linear Algebra
A matrix is a rectangular array of numbers arranged into rows and columns. We denote an m times n matrix as A in mathbb{R}^{m times n}, where m is the number of rows and n is the number of columns. The entry in row i and column j is written a_{ij}. In machine learning, a dataset with m examples and
A matrix is both a data container and a linear transformation.
Without matrix multiplication, there is no forward pass, no batching, no efficient use of the GPU โ every deep-learning library is built on top of this one operation.
A matrix is a rectangular array of numbers arranged into rows and columns. We denote an matrix as , where is the number of rows and is the number of columns. The entry in row and column is written . In machine learning, a dataset with examples and features is usually stored as such a matrix โ often called the design matrix.
Matrices support three fundamental operations. Addition and scalar multiplication work entry-wise and require matching dimensions (for addition). Matrix multiplication, in contrast, is subtler. The product is defined only when the number of columns of equals the number of rows of , and the entry of is the dot product of row of with column of : .
Matrix multiplication is not commutative: in general , even when both products are defined. It is, however, associative () and distributive over addition. These algebraic laws are what let us factor, rearrange, and decompose expressions in ML โ for example, when deriving the normal equations .
Special matrices show up everywhere. The identity matrix has ones on the diagonal and zeros elsewhere; it satisfies . The transpose flips rows and columns, and . A matrix is symmetric if (covariance matrices are always symmetric), diagonal if only the diagonal is non-zero, and orthogonal if (orthogonal matrices preserve lengths and angles โ think rotations and reflections).
The inverse , when it exists, satisfies . A matrix is invertible (also called *non-singular*) iff it is square and its columns are linearly independent. Not every matrix has an inverse โ for the ones that do not, we reach for generalized inverses like the MooreโPenrose pseudo-inverse, which is the beating heart of least-squares solutions.
Exercises
Put your understanding to the test. Score + streak + speed all count.
Confirm you've got it
3 quick questions. Get 2 right to mark this lesson complete.