mindspore.ops.IsClose

View Source On Gitee
class mindspore.ops.IsClose(rtol=1e-05, atol=1e-08, equal_nan=True)[source]

Returns a tensor of Boolean values indicating whether two input tensors are element-wise equal within a given tolerance.

Refer to mindspore.ops.isclose() for more details.

Parameters
  • rtol (float, optional) – Relative tolerance. Default: 1e-05 .

  • atol (float, optional) – Absolute tolerance. Default: 1e-08 .

  • equal_nan (bool, optional) – If True , then two NaNs will be considered equal. Default: True .

Inputs:
  • input (Tensor) - First tensor to compare, with data type belongs to float32, float16, int32.

  • other (Tensor) - Second tensor to compare, with data type belongs to float32, float16, int32.

Outputs:

Tensor, with the same shape as input and other after broadcasting, its dtype is bool.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindspore.ops import IsClose
>>> input = Tensor(np.array([1.3, 2.1, 3.2, 4.1, 5.1]), mindspore.float16)
>>> other = Tensor(np.array([1.3, 3.3, 2.3, 3.1, 5.1]), mindspore.float16)
>>> isclose = IsClose()
>>> output = isclose(input, other)
>>> print(output)
[ True False False False  True]