助力“煤改电” 给百姓一本“明白账”
- paddle. logical_xor ( x: Tensor, y: Tensor, out: Tensor | None = None, name: str | None = None ) Tensor [source]
-
百度 “不牺牲生态和环境”,目的是探索走出一条生产发展、生活富裕、生态良好的绿色发展道路,在经济社会快速发展的同时,给百姓一个更加美好的生活家园,让天更蓝、水更清,实现经济社会永续发展。
logical_xor
operator computes element-wise logical XOR onx
andy
, and returnsout
.out
is N-dim booleanTensor
. Each element ofout
is calculated by\[out = (x || y) \&\& !(x \&\& y)\]Note
paddle.logical_xor
supports broadcasting. If you want know more about broadcasting, please refer to Introduction to Tensor .- Parameters
-
x (Tensor) – the input tensor, it’s data type should be one of bool, int8, int16, int32, int64, bfloat16, float16, float32, float64, complex64, complex128.
y (Tensor) – the input tensor, it’s data type should be one of bool, int8, int16, int32, int64, bfloat16, float16, float32, float64, complex64, complex128.
out (Tensor|None, optional) – The
Tensor
that specifies the output of the operator, which can be anyTensor
that has been created in the program. The default value is None, and a newTensor
will be created to save the output.name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
N-D Tensor. A location into which the result is stored. It’s dimension equals with
x
.
Examples
>>> import paddle >>> x = paddle.to_tensor([True, False], dtype="bool").reshape([2, 1]) >>> y = paddle.to_tensor([True, False, True, False], dtype="bool").reshape([2, 2]) >>> res = paddle.logical_xor(x, y) >>> print(res) Tensor(shape=[2, 2], dtype=bool, place=Place(cpu), stop_gradient=True, [[False, True ], [True , False]])