How to do element wise multiplication in NumPy

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

How to do element wise multiplication in NumPy
How to do element-wise multiplication in NumPy
import numpy as np
a = np.array([[2,4],[6,8]])
b = np.array([[1,2],[3,4]])
print(np.multiply(a,b))

Output

[[ 2  8]
 [18 32]]

Leave a Comment

Your email address will not be published.