TUTORIALAI & dataFETCHED

PyTorch torch.bitwise_not 函数

PyTorch torch.bitwise_not 函数 PyTorch torch.bitwise_not 函数 Pytorch torch 参考手册 torch.bitwise_not 是 PyTorch 中用于逐元素按位取反的函数。 函数定义 torch.bitwise_not(input, *, out=None) 使用示例 实例 [mycode4 type='python'] imp..

Updated 7/16/2026

Tutorial detail pages default to noindex.

PyTorch torch.bitwise_not 函数

PyTorch torch.bitwise_not 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

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)

Pytorch torch 参考手册 Pytorch torch 参考手册