Multiple matrix multiplication

Use np.einsum

np.einsum('ijk,ik->ij',matrices,vectors)

Steps :

1) Keep the first axes aligned.

2) Sum-reduce the last axes from the input arrays against each other.

3) Let the remainining axes(second axis from matrices) be element-wise multiplied.

Leave a Comment