We have two tensors:
a = np.arange(8.).reshape(4,2,1) b = np.arange(16.).reshape(2,4,2)We are going to impliment
np.einsum('ijk,jil->kl', a, b)Although we could obtain its results, we were persist to understand the process details about the summation over tensors element.
Firstly we know how
np.einsum('jil', b)changes the elements' orders of b tensor.
but we cannot understand how np.einsum('ijk,jil->kl', a, b) combine (sums) tensors elements.
For tracking the process we used strings:
aa=[[['e'], ['r']], [['t'], ['y']], [['u'], ['o']], [['p'], ['q']]]and
bb=[[[ 'x', 'c'], [ 'v' , 'n'], [ 'm', 'h'], [ 'f' , 'd']], [[ 's', 'w'], [ 'a','z'], ['j', 'k'], ['l', 'b']]]Because we wanted to see how different elements combine for obtaining np.einsum('ijk,jil->kl', aa, bb)!
However np.einsum('jil', bb) works correctly but it did not show me the details of summation over elements.