np.dot()

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2024 Sep 21 15:55
Editor
Edited
Edited
2026 Jan 28 23:48
Refs
Refs
np.dot([1,2,3], [4,5,6]) # 32 (= 1*4 + 2*5 + 3*6)
  • last axis of first vector
  • second axis of second vector
# Let's create two 3D arrays to verify how the axes behave during np.dot and np.matmul operations. A_3d = np.random.rand(3, 4, 5) # shape: (3, 4, 5) B_3d = np.random.rand(3, 5, 6) # shape: (3, 5, 6) # Perform np.dot and np.matmul to observe the shapes result_dot_3d = np.dot(A_3d, B_3d) result_matmul_3d = np.matmul(A_3d, B_3d) # Display shapes of results to observe which axes are reduced result_dot_3d.shape, result_matmul_3d.shape # ((3, 4, 3, 6), (3, 4, 6))
 
 
 
 
 
 
 
 
 

Recommendations