PyTorch torch.le 函数

约 247 字 更新于 2026-11-18 5iyo.com

PyTorch torch.le 函数


torch.le 是 PyTorch 中用于逐元素小于等于比较的函数。

函数定义

torch.le(input, other, out)

使用示例

实例

import torch

# 逐元素小于等于比较
x = torch.tensor([1, 2, 3, 4])
y = torch.tensor([2, 2, 2, 5])

result = torch.le(x, y)
print(result)