Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.less_equal function

PyTorch torch.less_equal function


PyTorch torch reference manual PyTorch torch reference manual

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

Function definition

torch.less_equal(input, other)


Usage examples

Example

import

torch

Create two tensors

x

=

torch.

tensor

(

[

3

,

5

,

2

]

)

y

=

torch.

tensor

(

[

2

,

4

,

2

]

)

Element-wise less-than-or-equal comparison

result

=

torch.

less_equal

(

x

,

y

)

print

(

result

)

The output is:

tensor([False, False, True])


PyTorch torch reference manual PyTorch torch reference manual