How To Calculate The Outer Product Of Two Matrices A And B Per Rows Faster In Python (numpy)?
Let say we have two matrices A and B. A has the shape (r, k) and B has the shape (r, l). Now I want to calculate the np.outer product of these two matrices per rows. After the oute
Solution 1:
You could literally transfer the iterators as string notation to np.einsum
-
np.einsum('rk,rl->kl',A,B)
Or with matrix-multiplication using np.dot
-
A.T.dot(B)
Post a Comment for "How To Calculate The Outer Product Of Two Matrices A And B Per Rows Faster In Python (numpy)?"