Matrix Multiplication

Matrix multiplication is a mathematical operation between 2 matrices that returns a matrix.

For each row in the first matrix, take the Dot Productf each column in the second matrix. Place the results onto the corresponding row in a new matrix.

Matrix Multiplication example

The size of the new matrix will be the row count from the first matrix by the column count from the second.

It is only defined when the number of columns from the first matrix equals the number of rows in the second.

In Numpy the @ operator is used for matrix multiplication between 2 multi-dimensional arrays (matrices):

The same operator works in PyTorch:


Backlinks