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

31 lines
1.7 KiB
ReStructuredText
Raw Permalink 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.div
=================
.. py:function:: mindspore.ops.div(input, other, rounding_mode=None)
逐元素计算第一个输入Tensor除以第二输入Tensor的商。
`input``other` 的输入遵循隐式类型转换规则,使数据类型一致。
输入必须是两个Tensor或一个Tensor和一个Scalar。
当输入是两个Tensor时它们的数据类型不能同时为bool它们的shape可以广播。
当输入是一个Tensor和一个Scalar时Scalar只能是一个常量。
.. math::
out_{i} = input_{i} / other_{i}
参数:
- **input** (Union[Tensor, Number, bool]) - 第一个输入为数值型或bool或数据类型为数值型或bool的Tensor。
- **other** (Union[Tensor, Number, bool]) - 第二个输入当第一个输入是Tensor时第二个输入必须是一个数值型或bool或是数据类型为数值型或bool的Tensor。
- **rounding_mode** (str, 可选) - 应用于结果的舍入类型。三种类型被定义为None、"floor" 和 "trunc" 。默认值None。
- **None**: 默认行为。相当于Python中的 `true division` 或NumPy中的 `true_divide`
- **"floor"**: 将除法的结果向下舍入。相当于Python中的 `floor division` 或NumPy中的 `floor_divide`
- **"trunc"**: 将除法的结果舍入到零。相当于C语言风格的整数除法。
返回:
Tensor输出的shape与广播后的shape相同数据类型取两个输入中精度较高或数字较高的。
异常:
- **TypeError** - 如果 `input``other` 不是以下之一Tensor、Number、bool。
- **ValueError** - 如果 `rounding_mode` 不是以下之一None、"floor"、"trunc"。