mindspore.mint.allclose
- mindspore.mint.allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False)[源代码]
返回 input 中的所有元素与 other 的对应元素是否“接近”。其中“接近”的数学公式为:
\[|input-other| ≤ atol + rtol × |other|\]警告
这是一个实验性API,后续可能修改或删除。
- 参数:
input (Tensor) - 第一个输入tensor。
other (Tensor) - 第二个输入tensor。
rtol (Union[float, int, bool], 可选) - 相对容忍度。默认
1e-05。atol (Union[float, int, bool], 可选) - 绝对容忍度。默认
1e-08。equal_nan (bool, 可选) - 两个NaN是否被视为相同。默认
False。
- 返回:
布尔型标量。
- 支持平台:
Ascend
样例:
>>> import mindspore >>> import numpy as np >>> input = mindspore.tensor(np.array([1.3, 2.1, 3.2, 4.1, 5.1]), mindspore.float16) >>> other = mindspore.tensor(np.array([1.3, 3.3, 2.3, 3.1, 5.1]), mindspore.float16) >>> output = mindspore.mint.allclose(input, other) >>> print(output) False