mindspore.mint.cumprod

查看源文件
mindspore.mint.cumprod(input, dim, dtype=None)[源代码]

返回tensor在指定维度上累积的元素乘积。

\[y_i = x_1 * x_2 * x_3 * ... * x_i\]
参数:
  • input (Tensor) - 输入tensor。

  • dim (int) - 指定计算维度。

  • dtype (mindspore.dtype, 可选) - 返回的数据类型。默认 None

返回:

Tensor

支持平台:

Ascend

样例:

>>> import mindspore
>>> input = mindspore.tensor([[1, 2, 3],
...                           [4, 5, 6]])
>>> mindspore.mint.cumprod(input, dim=0)
Tensor(shape=[2, 3], dtype=Int64, value=
[[ 1,  2,  3],
 [ 4, 10, 18]])
>>> mindspore.mint.cumprod(input, dim=1)
Tensor(shape=[2, 3], dtype=Int64, value=
[[  1,   2,   6],
 [  4,  20, 120]])