-1

I have a 1-d pytorch tensor and I got topk data of the tensor and indeces of this datas. How can I place each data in the corresponding position of a empty pytorch tensor?

The topk of this tensor elements and their indeces is got by: value, indeces = toech.topk(T,K) and I also have an empty tensor t of the same size as T. How can I copy each value[i] to t[indeces[i]]? I have tried to use for i in value but this way is too slow when data isn't very small.

CXLi
  • 3
  • 1

1 Answers1

0

This should work:

t[indeces] = value
Toyo
  • 667
  • 1
  • 5
  • 22