1. 線性代數中矩陣乘法: np.dot()
import numpy as np # 2 x 3 matrix1 = np.array([[1, 2, 3], [4, 5, 6]]) # 3 x 2 matrix2 = np.array([[1, 2], [3, 4], [5, 6]]) multi = np.dot(matrix1, matrix2) print(multi)
2. 對應元素相乘 np.multiply()或 *
matrix3 = np.array([[1, 2, 3], [4, 5, 6]]) matrix4 = np.array([[1, 2, 3], [4, 5, 6]]) multi2 = np.multiply(matrix3, matrix4) print(multi2)