equal

paddle.compat. equal ( input: Tensor, other: Tensor ) bool [source]

True if two tensors have the same size and elements, False otherwise.

Note

Tensors containing NaNs are never equal to each other. Additionally, this function does not differentiate between the data types of the tensors during comparison.

Parameters
  • input (Tensor) – Tensor, data type is bool, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.

  • other (Tensor) – Tensor, data type is bool, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.

Returns

True if two tensors have the same size and elements, False otherwise.

Return type

Bool

Examples

>>> import paddle

>>> x = paddle.to_tensor([1, 2, 3])
>>> y = paddle.to_tensor([1, 3, 2])
>>> result1 = paddle.compat.equal(x, y)
>>> print(result1)
False