I meet a problem that, how to get the index of a element in a Tensor whose value is True?
Such as, a Tensor like:
False False Fasle
Flase True False
False False False
Then I can get the index of (1,1).
So how can I implement this operation?
Your answer and idea will be appreciated!
nonzero() would return you the indices of all non-zero entries (in that case
x = torch.bernoulli(torch.ones(3, 3) * 0.5).bool()
> tensor([[ True, True, False],
[False, False, True],
[ True, False, False]])
> tensor([[0, 0],
Thanks sincerely for your answer and guide!