How to index a tensor with two longTensor?

somthing equivalent to the following numpy code.
Thanks!

import numpy as np
data = np.random.rand(4,5,6)
first = np.array([0,1,2])
second = np.array([2,3,1])

res = data[first, second]

print(res)

this is not yet possible, but we are working on Advanced Indexing. We will have it by release 0.2

you can follow this issue for progress: https://github.com/pytorch/pytorch/issues/1080

1 Like