Array vs Matrix
import numpy as np
mat_a = np.mat('1 2; 3 4')
mat_b = np.mat('5 6; 7 8')
mat_a
matrix([[1, 2],
[3, 4]])
ar_a = np.array([
[1, 2],
[3, 4]
])
ar_b = np.array([
[5, 6],
[7, 8]
])
ar_a
array([[1, 2],
[3, 4]])
# Matrix multiplication
mat_c = mat_a * mat_b
mat_c
matrix([[19, 22],
[43, 50]])
# Numpy array multiplication (element wise)
ar_c = ar_a * ar_b
ar_c
array([[ 5, 12],
[21, 32]])
# Numpy dot multiplication
ar_d = np.dot(ar_a, ar_b)
# We can also use @
ar_d = ar_a @ ar_b
ar_d
array([[19, 22],
[43, 50]])
More explained here: