I have following four tensors
- H (h, r)
- A (a, r)
- D (d, r)
- T (a, t, r)
For each i
in a
, there is a corresponding T[i]
of the shape (t, r)
.
I need to do a np.einsum
to produce the following result (pred
):
pred = np.einsum('hr, ar, dr, tr ->hadt', H, A, D, T[0])
for i in range(a):
pred[:, i:i+1, :, :] = np.einsum('hr, ar, dr, tr ->HADT', H, A[i:i+1], D, T[i])
However, I want to do this computation without using a for loop. The reason is that I' m using autograd
which doesn't currently work with item assignments!