TUTORIALAI 与数据科学FETCHED
PyTorch torch.ne 函数
PyTorch torch.ne 函数 Pytorch torch 参考手册 torch.ne 是 PyTorch 中用于逐元素不等比较的函数。 函数定义 torch.ne(input, other, out) 使用示例 实例 [mycode4 type='python'] import torch a = torch.tensor([1, 2, 3, 4]) b = torch.tensor(..
更新于 2026/7/16
教程详情页默认 noindex。
PyTorch torch.ne 函数
torch.ne 是 PyTorch 中用于逐元素不等比较的函数。
函数定义
torch.ne(input, other, out)
使用示例
实例
import torch
a = torch.tensor([1, 2, 3, 4])
b = torch.tensor([1, 2, 0, 4])
result = torch.ne(a, b)
print(result)
a = torch.tensor([1, 2, 3, 4])
b = torch.tensor([1, 2, 0, 4])
result = torch.ne(a, b)
print(result)
输出结果为:
tensor([False, False, True, False])
Pytorch torch 参考手册