PyTorch torch.bitwise_not 函数
torch.bitwise_not 是 PyTorch 中用于逐元素按位取反的函数。
函数定义
torch.bitwise_not(input, *, out=None)
使用示例
实例
import torch
# 按位取反示例
x = torch.tensor([0, 1, 2, 3], dtype=torch.int8)
result = torch.bitwise_not(x)
print(result) # tensor([-1, -2, -3, -4], dtype=int8)
# 按位取反示例
x = torch.tensor([0, 1, 2, 3], dtype=torch.int8)
result = torch.bitwise_not(x)
print(result) # tensor([-1, -2, -3, -4], dtype=int8)

Pytorch torch 参考手册