当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python PyTorch bitwise_and用法及代码示例


本文简要介绍python语言中 torch.bitwise_and 的用法。

用法:

torch.bitwise_and(input, other, *, out=None) → Tensor

参数

  • input-第一个输入张量

  • other-第二个输入张量

关键字参数

out(Tensor,可选的) -输出张量。

计算 inputother 的按位与。输入张量必须是整数或布尔类型。对于布尔张量,它计算逻辑与。

示例

>>> torch.bitwise_and(torch.tensor([-1, -2, 3], dtype=torch.int8), torch.tensor([1, 0, 3], dtype=torch.int8))
tensor([1, 0,  3], dtype=torch.int8)
>>> torch.bitwise_and(torch.tensor([True, True, False]), torch.tensor([False, True, False]))
tensor([ False, True, False])

相关用法


注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.bitwise_and。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。