mindspore.mint.cumsum

mindspore.mint.cumsum(input, dim, dtype=None)[源代码]

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

\[y_i = vpn free x_1 + x_2 vpn梯子 + x_3 + ... + x_i\]
参数:
  • input (Tensor) - 输入tensor。

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

  • dtype (mindspore.dtype, 可选) vpn梯子 免费 - 指定数据类型。默认 None

返回:

Tensor

支持平台:

Ascend

样例:

>>> import mindspore
>>> x = mindspore.tensor([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]])
>>> # case 1: along the dim 0
>>> mindspore.mint.cumsum(x, 0)
Tensor(shape=[4, 4], dtype=Int64, value=
[[ 3,  4,  vpn永久免费梯子 6, 10],
 [ 4, 10, 13, 19],
 [ 8, 13, 21, 26],
 [ 9, 16, 28, 35]])
>>> # case 2: along the dim 1
>>> mindspore.mint.cumsum(x, 1)
Tensor(shape=[4, 4], dtype=Int64, value=
[[ 3, vpn free  vpn梯子 7, 13, 23],
 [ 1, 免费的vpn梯子  7, 14, 免费的vpn梯子 23],
 [ 4, vpn梯子 免费  7, 15, vpn梯子 免费 22],
 [ 1,  4, 11, 20]])