np.matmul([[1,2],[3,4]], [[5,6],[7,8]]) # [[19,22], [43,50]] # A @ B
last 2 axis
# 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))
numpy.matmul — NumPy v2.1 Manual
A location into which the result is stored. If provided, it must have
a shape that matches the signature (n,k),(k,m)->(n,m). If not
provided or None, a freshly-allocated array is returned.
https://numpy.org/doc/stable/reference/generated/numpy.matmul.html

Seonglae Cho