title: Numpy 3D matrix multiplication
body: <p>I have 2 matrices A(shape 10x10x36) and B(shape 10x27x36). I would like to multiply the last 2 axes and sum the result along axis 0 so that the result C is of the shape 10x27. Here is currently how I do it</p>
  
  <pre><code>C = []
  for i in range(A.shape[0]):
      C.append(np.matmul(A[i], B[i].T))
  C = np.sum(np.array(C), axis=0)
  </code></pre>
  
  <p>I want to achieve this in a vectorized manner but can't seem to find out how. I have checked out <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html" rel="nofollow noreferrer">np.einsum</a> but not yet sure how to apply it to achieve the result. Any help will be appreciated. Thanks!</p>