PyTorch torch.less Function
PyTorch torch Reference Manual
torch.lessIt is a function in PyTorch used for element-wise comparison of less than. Returns a tensor where the elements of the first tensor are less than the corresponding elements of the second tensor at positions that are True.
Function Definition
torch.less(input, other)
Usage Example
Example
import torch
# Create two tensors
x = torch.tensor([3, 5, 2])
y = torch.tensor([2, 4, 2])
# Element-wise comparison of less than
result = torch.less(x, y)
print(result)
# Create two tensors
x = torch.tensor([3, 5, 2])
y = torch.tensor([2, 4, 2])
# Element-wise comparison of less than
result = torch.less(x, y)
print(result)
The output result is:
tensor([False, False, False])
Other Extensions