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 |
In[39]: a>0 Out[39]: tensor([[1, 1, 0, 1, 0, 1, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 0]], dtype=torch.uint8) In[40]: torch.gt(a,0) Out[40]: tensor([[1, 1, 0, 1, 0, 1, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 0]], dtype=torch.uint8) In[41]: a!=0 Out[41]: 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) In[42]: a = torch.ones(2,3) In[43]: b = torch.randn(2,3) In[44]: torch.eq(a,b) Out[44]: tensor([[0, 0, 0], [0, 0, 0]], dtype=torch.uint8) In[45]: torch.eq(a,a) Out[45]: tensor([[1, 1, 1], [1, 1, 1]], dtype=torch.uint8) In[46]: torch.equal(a,a) Out[46]: True |