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

28 lines
1.6 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.ReduceProd
==========================
.. py:class:: mindspore.ops.ReduceProd(keep_dims=False)
默认情况下使用指定维度所有元素的乘积代替该维度的其他元素以移除该维度。也可仅缩小该维度大小至1。
通过指定 `keep_dims` 参数,来控制输出和输入的维度是否相同。
参数:
- **keep_dims** (bool) - 如果为True则保留缩小的维度大小为1。否则移除维度。默认值False。
输入:
- **x** (Tensor[Number]) - 输入Tensor其数据类型为数值型。shape :math:`(N, *)` ,其中 :math:`*` 表示任意数量的附加维度。秩应小于8。
- **axis** (Union[int, tuple(int), list(int)]) - 要减少的维度。默认值:(),缩小所有维度。只允许常量值。假设 `x` 的秩为r取值范围[-r,r)。
输出:
与输入 `x` 具有相同数据类型的Tensor。
- 如果 `axis` 为(),且 `keep_dims` 为False则输出一个零维Tensor表示输入Tensor中所有元素的乘积。
- 如果 `axis` 为int取值为1并且 `keep_dims` 为False则输出的shape为 :math:`(x_0, x_2, ..., x_R)`
- 如果 `axis` 为tuple(int)或list(int),取值为(1, 2),并且 `keep_dims` 为False则输出Tensor的shape为 :math:`(x_0, x_3, ..., x_R)`
异常:
- **TypeError** - `keep_dims` 不是bool类型。
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `axis` 不是以下数据类型之一int、Tuple或List。
- **ValueError** - `axis` 超出范围。