mindspore.numpy.cumprod

mindspore.numpy.cumprod(a, axis=None, dtype=None)[源代码]

Returns the cumulative product of elements along a given axis.

Note

Numpy argument out is not supported.

Parameters
  • a (Union[int, float, bool, list, tuple, Tensor]) – Input tensor.

  • axis (int, optional) – Axis along which the cumulative product is computed. By default the input is flattened. Default: None.

  • dtype (mindspore.dtype, optional) – Default: None. Overrides the dtype of the output Tensor.

Returns

Tensor.

Raises
  • TypeError – If the input can not be converted to tensor or axis is not integer.

  • ValueError – If axis is out of range.

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore.numpy as np
>>> x = np.array([1, 2, 3])
>>> print(np.cumprod(x))
[1 2 6]