Understanding NumPy’s einsum

I’m struggling to understand exactly how einsum works. I’ve looked at the documentation and a few examples, but it’s not seeming to stick.

Here’s an example we went over in class:

C = np.einsum("ij,jk->ki", A, B)

for two arrays: A and B.

I think this would take A^T * B, but I’m not sure (it’s taking the transpose of one of them right?). Can anyone walk me through exactly what’s happening here (and in general when using einsum)?

8 Answers
8

Leave a Comment