numpy matrix multiplication

Multiplication sign *

numpy matrix is ​​mainly in two forms, numpy.mat and numpy.ndarray. Using multiplication time to pay attention, if it is ndarray default is the number of the plot, which is multiplied by the corresponding point. And if it is, then the mat is vector product, which is the general matrix multiplication format.

a = np.arange(4)
a = a.reshape((2,2))
a_t = np.transpose(a)

print(a)
print(a_t)

print(type(a))
print(a * a_t)

b = np.asmatrix(a)
print(type(b))
b_t = np.asmatrix(a_t)
print(b * b_t)

 

dot()

follow the dot matrix-vector product, i.e. general matrix multiplication.

Guess you like

Origin www.cnblogs.com/siren27/p/12157293.html