If I create an array of 1’s as torch.uint8. And I use ~ on this array I get an array of 0’s. I thought ~ is supposed to invert bits so technically shouldn’t we get an array of 254? It seems that I am getting 1-x for x being the uint8 number I want to invert with ~.
Just another user but I agree, it’s weird, especially because calling t.neg()
does get you 255
's instead.
But I’m using byte tensors as arrays of boolean values so the current behavior of ~
is exactly what I need.