tensor_a is of shape (256, 4, 64) and tensor_b is of shape (256, 64, 1)
res = None
for u in range(256):
temp = torch.matmul(tensor_a[u, :, :], tensor_b)
temp = temp.sum().unsqueeze(-1)
if u == 0:
res = temp
else:
res = torch.cat((res, temp), -1)
res = res.unsqueeze(-1)
Can anyone get the result using torch functions rather than use looping?