matrix multiplication is something we’ve all done at some point.
while some of y’all still do stuff that require matrix multiplication, most of y’all don’t
none the less if you’re reading this you’re curious why we do
answering that would need some digging into the concept of matrix(s)
spoiler: it's really intuitive once you remember that matrices represent something
here’s a video version of this blog post https://youtu.be/hVZD4OvlV3w
what does a matrix represent?
a matrix is a 2d tensor
a tensor is an n-dimentional array that holds different values for different parameters of the array
pretty sure that definition doesn’t help but think of a matrix to be an *excel/SQL table*
let’s take an example: list of items in my bag, converting that from a table to a matrix would look like:
this is technically an array, but to make this a matrix, let’s add one dimension i.e, parameter to the array
ohh this is the computer science representation of a matrix by the way
the math representation is pretty straight forward, remove the tables and draw those brackets 👀
what about matrix multiplication?
just remembering that the matrix represents something and performing normal multiplication keeping in mind the parameters should make you intuitively perform that pattern
don’t believe em?? let’s run through an example
here’s the distances Suraj and Arjun travelled in the months of jan, feb and march and here’s the petrol prizes for the months
now calculate the total money spent on petrol by both Suraj and Arjun without thinking about matrices
now try with the matrix multiplication method
this is also why the inner dimensions have to match, i,e they have to be the same parameters to make sense in terms of what we are multiplying
@ is the symbol for matrix multiplication in python
and why the shape of the result is the outer dimension
untill next time !️ ✌
or you could spot me in the wild 🤭 i mean instagram, twitter, linkedin and maybe even youtube where i excalidraw those diagrams