mindspore/docs/api/api_python/ops/mindspore.ops.func_isclose.rst

37 lines
1.6 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.isclose
=====================
.. py:function:: mindspore.ops.isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False)
返回一个布尔型Tensor表示 `x1` 的每个元素与 `x2` 的对应元素在给定容忍度内是否“接近”,其中“接近”的数学公式为:
.. math::
x1x2 ≤ atol + rtol × x2
.. note::
目前Ascend后端不支持包含 inf 或 NaN 的输入数组。因此当输入包含NaN或inf时结果是不确定的。在Ascend后端上 `equal_nan` 必须为真。
**参数:**
- **x1** (Tensor) - 对比的第一个输入支持的类型有float32float16int32。
- **x2** (Tensor) - 对比的第二个输入支持的类型有float32float16int32。
- **rtol** (float, optional) - 相对容忍度。默认值1e-05。
- **atol** (float, optional) - 绝对容忍度。默认值1e-08。
- **equal_nan** (bool, optional) - 若为True则两个NaN被视为相同。默认值False。
**返回:**
Tensorshape与广播后的shape相同数据类型是布尔型。
**异常:**
- **TypeError** - `x1``x2` 中的任何一个不是Tensor。
- **TypeError** - `x1``x2` 的数据类型不是float16、float32或int32之一。
- **TypeError** - `atol``rtol` 中的任何一个不是float。
- **TypeError** - `equal_nan` 不是bool。
- **TypeError** - `x1``x2` 的数据类型不同。
- **ValueError** - `x1``x2` 无法广播。
- **ValueError** - `atol``rtol` 中的任何一个小于零。
- **ValueError** - Ascend平台上的 `equal_nan` 为False。