python - Speed up multilple matrix products with numpy -


in python have 2 3 dimensional arrays:

t size (n,n,n)

u size (k,n,n)

t , u can seen many 2-d arrays 1 next other. need multiply matrices, ie have perform following operation:

for in range(n):         h[:,:,i] =  u[:,:,i].dot(t[:,:,i]).dot(u[:,:,i].t) 

as n might big wondering if operation in way speed numpy.

carefully looking iterators , how involved in dot product reductions, translate of 1 np.einsum implementation -

h = np.einsum('ijk,jlk,mlk->imk',u,t,u) 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -