Boolean between ByteTensor


(Ruotian(RT) Luo) #1

I was trying to get a mask from multiple conditions like x > 0.5 and x<1
however, if x is a tensor, current framework doesn’t support it.

What I’m doing now is

(x>0.5 + x<1) == 2

I feel like this would be slower than boolean calculation if there were a boolean calculation.

Is there any other more decent way?


(Thomas V) #2

I’d think multiplication is more canonical…


(Ruotian(RT) Luo) #3

Ok. then what about or.


(Thomas V) #4
r = torch.randn(10)
print ((r<-1) | (r>1))

(& also works for and)

Best regards

Thomas