I just digged a little bit deeper and I found the numpy function einsum. This gives a lot of freedom for doing vector multiplications.
a = np.zeros([7200,13,4])
b = np.zeros([7200,4,7])
c = np.einsum('ijk,ikl->ijl',a,b)
c.shape (7200, 13, 7)
Question
I am looking for an efficient way to perform a matrix multiplication (dot product) of two time-dependent 2D matrices to end up with one time-dependent 2D matrix.
For example:
a = np.zeros([7200,13,4])
b = np.zeros([7200,4,7])
And I want to end up with
c = np.zeros([7200,13,7])
I already found np.tensordot, however this yields me a 4D matrix instead of a 3D matrix. Also other numpy functions did not yield me the required shape. So I wonder if there is any way to perform this matrix multiplication without the use of for-loops?
Best regards,
Timothy Van Daele
Solution
I just digged a little bit deeper and I found the numpy function einsum. This gives a lot of freedom for doing vector multiplications.
a = np.zeros([7200,13,4])
b = np.zeros([7200,4,7])
c = np.einsum('ijk,ikl->ijl',a,b)
c.shape (7200, 13, 7)