*Memos:
- My post explains ge() and le().
- My post explains eq() and ne().
- My post explains isclose() and equal().
gt() can check if the zero or more elements of the 1st 0D or more D tensor are greater than the zero or more elements of the 2nd 0D or more D tensor element-wise, getting the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
gt()can be used with torch or a tensor. - The 1st argument(
input) withtorchor using a tensor(Required-Type:tensorofint,floatorbool). - The 2nd argument with
torchor the 1st argument with a tensor isother(Required-Type:tensororscalarofint,floatorbool). - There is
outargument withtorch(Optional-Default:None-Type:tensor): *Memos:-
out=must be used. -
My post explains
outargument.
-
-
greater() is the alias of
gt().
import torch
tensor1 = torch.tensor([5, 0, 3])
tensor2 = torch.tensor([3, 5, 4])
torch.gt(input=tensor1, other=tensor2)
tensor1.gt(other=tensor2)
# tensor([True, False, False])
torch.gt(input=tensor2, other=tensor1)
# tensor([False, True, True])
tensor1 = torch.tensor([5, 0, 3])
tensor2 = torch.tensor([[3, 5, 4],
[6, 3, 5]])
torch.gt(input=tensor1, other=tensor2)
# tensor([[True, False, False],
# [False, False, False]])
torch.gt(input=tensor2, other=tensor1)
# tensor([[False, True, True],
# [True, True, True]])
torch.gt(input=tensor1, other=3)
# tensor([True, False, False])
torch.gt(input=tensor2, other=3)
# tensor([[False, True, True],
# [True, False, True]])
tensor1 = torch.tensor([5., 0., 3.])
tensor2 = torch.tensor([[3., 5., 4.],
[6., 3., 5.]])
torch.gt(input=tensor1, other=tensor2)
# tensor([[True, False, False],
# [False, False, False]])
torch.gt(input=tensor1, other=3.)
# tensor([True, False, False])
tensor1 = torch.tensor([True, False, True])
tensor2 = torch.tensor([[True, False, True],
[False, True, False]])
torch.gt(input=tensor1, other=tensor2)
# tensor([[False, False, False],
# [True, False, True]])
torch.gt(input=tensor1, other=True)
# tensor([False, False, False])
lt() can check if the zero or more elements of the 1st 0D or more D tensor are less than the zero or more elements of the 2nd 0D or more D tensor element-wise, getting the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
lt()can be used withtorchor a tensor. - The 1st argument(
input) withtorchor using a tensor(Required-Type:tensorofint,floatorbool). - The 2nd argument with
torchor the 1st argument with a tensor isother(Required-Type:tensororscalarofint,floatorbool). - There is
outargument withtorch(Optional-Default:None-Type:tensor): *Memos:-
out=must be used. -
My post explains
outargument.
-
-
less() is the alias of
lt().
import torch
tensor1 = torch.tensor([5, 0, 3])
tensor2 = torch.tensor([3, 5, 4])
torch.lt(input=tensor1, other=tensor2)
tensor1.lt(other=tensor2)
# tensor([False, True, True])
torch.lt(input=tensor2, other=tensor1)
# tensor([True, False, False])
tensor1 = torch.tensor([5, 0, 3])
tensor2 = torch.tensor([[3, 5, 4],
[6, 3, 5]])
torch.lt(input=tensor1, other=tensor2)
# tensor([[False, True, True],
# [True, True, True]])
torch.lt(input=tensor2, other=tensor1)
# tensor([[True, False, False],
# [False, False, False]])
torch.lt(input=tensor1, other=3)
# tensor([False, True, False])
torch.lt(input=tensor2, other=3)
# tensor([[False, False, False],
# [False, False, False]])
tensor1 = torch.tensor([5., 0., 3.])
tensor2 = torch.tensor([[3., 5., 4.],
[6., 3., 5.]])
torch.lt(input=tensor1, other=tensor2)
# tensor([[False, True, True],
# [True, True, True]])
torch.lt(input=tensor1, other=3.)
# tensor([False, True, False])
tensor1 = torch.tensor([True, False, True])
tensor2 = torch.tensor([[True, False, True],
[False, True, False]])
torch.lt(input=tensor1, other=tensor2)
# tensor([[False, False, False],
# [False, True, False]])
torch.lt(input=tensor1, other=True)
# tensor([False, True, False])
Top comments (0)