pytorch: RuntimeError: bool value of Tensor with more than one value is ambiguous
it works with         

x[x &gt;= 0.2] = 1
x[x &lt; 0.2] = 0 


x is a tensor here.

but when i am trying to use         

x[x &gt; 0 and x &lt; 1] = 1


it reports: RuntimeError: bool value of Tensor with more than one value is ambiguous ?

dose anyone know why?

Just a syntax thing.

x = torch.randn((1,3,20,20))
x[(x &gt; 0) &amp; (x &lt; 1)] = 1

