• 文档 >
  • torch >
  • torch.logical_not
快捷键

torch.logical_not

torch.logical_not(input, *, out=None) Tensor

计算给定输入张量的逐元素逻辑非。如果未指定,输出张量将具有 bool 数据类型。如果输入张量不是 bool 张量,则将零视为 False ,非零视为 True

参数:

input (Tensor) – 输入张量。

关键字参数:

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

示例:

>>> torch.logical_not(torch.tensor([True, False]))
tensor([False,  True])
>>> torch.logical_not(torch.tensor([0, 1, -10], dtype=torch.int8))
tensor([ True, False, False])
>>> torch.logical_not(torch.tensor([0., 1.5, -10.], dtype=torch.double))
tensor([ True, False, False])
>>> torch.logical_not(torch.tensor([0., 1., -10.], dtype=torch.double), out=torch.empty(3, dtype=torch.int16))
tensor([1, 0, 0], dtype=torch.int16)

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源