TUTORIALAI 与数据科学FETCHED
PyTorch torch.bitwise_and 函数
PyTorch torch.bitwise_and 函数 PyTorch torch.bitwise_and 函数 Pytorch torch 参考手册 torch.bitwise_and 是 PyTorch 中用于逐元素按位与的函数。 函数定义 torch.bitwise_and(input, other, *, out=None) 使用示例 实例 [mycode4 type='python'..
更新于 2026/7/16
教程详情页默认 noindex。
PyTorch torch.bitwise_and 函数
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 参考手册