bitwise_not

paddle. bitwise_not ( x, out=None, name=None ) [源代码]

对 Tensor x 逐元素进行 按位取反 运算。

\[Out = \sim X\]

注解

paddle.bitwise_not 遵守 broadcasting,如您想了解更多,请参见 Tensor 介绍 .

参数

  • x (Tensor)- 输入的 N-D Tensor,数据类型为:bool,uint8,int8,int16,int32,int64。

  • out (Tensor,可选)- 输出的结果 Tensor,是与输入数据类型相同的 N-D Tensor。默认值为 None,此时将创建新的 Tensor 来保存输出结果。

返回

按位取反 运算后的结果 Tensor,数据类型与 x 相同。

代码示例

>>> import paddle
>>> x = paddle.to_tensor([-5, -1, 1])
>>> res = paddle.bitwise_not(x)
>>> print(res)
Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
[ 4,  0, -2])