I have a tensor called idx
which has integers from 0
to 27
. For instance
idx = torch.tensor([9, 0, 6, 5, 2, 1, 10, 18, 26, 0, 11])
I want to generate another array/tensor which has boolean values. I want the value to be True when it is strictly between 1
(on the left) and 0
(on the right).
flag = torch.tensor([False, False, False, False, False, False, True, True, True, False, False])
Is there a fast way to do this without an expensive for loop? Or if the for-loop is unavoidable, what’s the most efficient way to do this?