pytorch--BoolTensor进行逻辑运算操作

since pytorch 1.2, there is a dtype torch.bool and associated BoolTensor. The bitwise operators aka numpy (and &, or |, xor ^ and not ~) all work on these as logical operations.

BoolTensor在pytorch1.2后引入,针对BoolTensor才有了如下逻辑运算(dtype为bool型)

  • 与操作:a & b
  • 或操作:a | b
  • 异或操作:a ^ b
  • 取反操作:~a

参考自Implementing element-wise logical and tensor operation

你可能感兴趣的:(pytorch)