TUTORIALAI & dataFETCHED
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(..
Updated 7/16/2026
Tutorial detail pages default to 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 参考手册