How to do matrix multiplication in NumPy

You can do matrix multiplication in NumPy with the following code. If you want to learn Python, I highly recommend reading This Book.

How to do matrix multiplication in NumPy
How to do matrix multiplication in NumPy

Example 1

import numpy as np
a = np.array([[2,4],[6,8]])
b = np.array([[1,2],[3,4]])
c = np.dot(a,b) 
print(c)

Output

[[14 20]
 [30 44]]

Example 2

import numpy as np
a = np.array([[1,2,3],[4,5,6]])
b = np.array([[5,10],[2,4],[1,2]])
c = np.dot(a,b) 
print(c)

Output

[[12 24]
 [36 72]]

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.