PyTorch torch.bitwise_and 函数
torch.bitwise_and 是 PyTorch 中用于逐元素按位与的函数。
函数定义
torch.bitwise_and(input, other, *, out=None)
使用示例
实例
import torch
# 按位与示例
x = torch.tensor([5, 3, 7], dtype=torch.int8)
y = torch.tensor([1, 3, 4], dtype=torch.int8)
result = torch.bitwise_and(x, y)
print(result) # tensor([1, 3, 4], dtype=int8)
# 按位与示例
x = torch.tensor([5, 3, 7], dtype=torch.int8)
y = torch.tensor([1, 3, 4], dtype=torch.int8)
result = torch.bitwise_and(x, y)
print(result) # tensor([1, 3, 4], dtype=int8)

Pytorch torch 参考手册