I can’t figure it out with gather, according to its syntax:
torch.gather(input, dim, index, out=None)
gather can only handle one dimensional indexing.
For the time being, I do the indexing via python loop:
a1 = torch.stack([t1[Idx1[i],Idx2[i]] for i in range(3)])
in which
Idx1 = torch.LongTensor([1,3,0]) and Idx2 = torch.LongTensor([1,3,4])
Apparently this is not an efficient nor an elegant way.