1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
>>> a = torch.randn(4, 10) >>> >>> a > 0 tensor([[1, 1, 0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 0], [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]], dtype=torch.uint8) >>> >>> torch.gt(a, 0) tensor([[1, 1, 0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 0], [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]], dtype=torch.uint8) >>> >>> a != 0 tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], dtype=torch.uint8) >>> >>> a = torch.ones(2, 3) >>> >>> b = torch.randn(2, 3) >>> >>> torch.eq(a, b) tensor([[0, 0, 0], [0, 0, 0]], dtype=torch.uint8) >>> >>> torch.eq(a, a) tensor([[1, 1, 1], [1, 1, 1]], dtype=torch.uint8) >>> >>> torch.equal(a, a) True
|
近期评论