torch.lt/torch.gt/torch.le/torch.ge/torch.ne

Reason is the light and the light of life.

Jerry Su Jan 14, 2021 1 mins

https://pytorch.org/docs/stable/torch.html#comparison-ops

import torch
a = torch.randint(0, 10, [5])
b = torch.randint(0, 10, [5])
print(a)
print(b)
tensor([9, 0, 9, 2, 4])
tensor([7, 8, 5, 3, 6])
a.lt(b)         # <
tensor([False,  True, False,  True,  True])
torch.le(a, b) # <=
tensor([False,  True, False,  True,  True])
a.gt(b)        # >
tensor([ True, False,  True, False, False])
a.ge(b)        # >=
tensor([ True, False,  True, False, False])
a.ne(b)       # !=
tensor([True, True, True, True, True])



Read more:

Related posts: