PyTorch torch.less_equal Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.less_equalIt is a function in PyTorch used for element-wise comparison of less than or equal. It returns a tensor with True at positions where the first tensor element is less than or equal to the corresponding element of the second tensor.

Function Definition

torch.less_equal(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 or equal
result = torch.less_equal(x, y)
print(result)

The output result is:

tensor([False, False, True])

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions