...

/

Matrix Vector Multiplication

Matrix Vector Multiplication

In this lesson, we will look at some basic multiplication operations between matrices and vectors.

Matrix multiplication with vectors

Let us first see how we can multiply a matrix with a vector. PyTorch provides the mv() function for this purpose.

We can use mv() in two ways. mv() could be called from a tensor, or just call it from torch.mv(). The first parameter for torch.mv() is a matrix.

result = torch.mv(mat, vec)
result = mat.mv(vec)
...