Matrix Multiplication
Learn the concept of matrix multiplication and implement it in Python.
One of the most commonly used operations in data science is matrix multiplication. Because of its frequency in predictive models (including deep neural networks), a lot of attention has been devoted to making matrix multiplication more efficient in recent years. Today, we even have special hardware for fast matrix multiplication. In this lesson, we’ll learn about matrix multiplication and different ways to do it.
The dimensions rule
Not every pair of matrices can be multiplied together. Two matrices are multipliable if the number of columns, , in the first matrix equals the number of rows in the second matrix.
In other words, we can multiply any two matrices having equal inner dimensions, and the result would be a new matrix with an order equaling the outer dimensions:
Dot product
The simplest way to understand matrix multiplication is through dot product. The dot product of two vectors is simply the sum of products of corresponding elements. Consider the vectors and . The dot product of and is . A general representation of a dot product is
The same dot product can be used to represent matrix multiplication. Consider the matrices , a row matrix and , a column matrix.
In general, an element of matrix is a result of the multiplication of the vector in the th row vector of with the vector in the th column of .
...