Shortcuts

torch.ne

torch.ne(input, other, *, out=None) 张量

计算 inputother\text{input} \neq \text{other} 逐元素。

第二个参数可以是一个数字或一个张量,其形状与第一个参数是可广播的

Parameters
Keyword Arguments

输出 (张量, 可选) – 输出张量。

Returns

一个布尔张量,在 input 不等于 other 的地方为 True,其他地方为 False

示例:

>>> torch.ne(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]]))
tensor([[False, True], [True, False]])
优云智算