mindspore.mint.prod
- mindspore.mint.prod(input, *, dtype=None) Tensor[source]
Multiply all elements of input.
- Parameters
input (Tensor[Number]) – The input tensor.
- Keyword Arguments
dtype (
mindspore.dtype, optional) – Specify data type. DefaultNone.- Returns
Tensor.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> x = mindspore.tensor([[[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]], ... [[4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]], ... [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9]]], mindspore.float32) >>> output = mindspore.mint.prod(x) >>> print(output) 2.2833798e+33 >>> print(output.shape) ()
Reduce a dimension of a tensor by multiplying all elements in the dimension, by default. And also can reduce a dimension of input along the dim. Determine whether the dimensions of the output and input are the same by controlling keepdim.
- Parameters
- Keyword Arguments
dtype (
mindspore.dtype, optional) – Specify data type. DefaultNone.- Returns
Tensor.
If dim is int, set as 1, and keepdim is
False, the shape of output is \((input_0, input_2, ..., input_R)\).
- Raises
ValueError – If dim is out of range.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> x = mindspore.tensor([[[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]], ... [[4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]], ... [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9]]], mindspore.float32) >>> mindspore.mint.prod(x, 0, True) Tensor(shape=[1, 3, 6], dtype=Float32, value= [[[ 2.80000000e+01, 2.80000000e+01, 2.80000000e+01, 2.80000000e+01, 2.80000000e+01, 2.80000000e+01], [ 8.00000000e+01, 8.00000000e+01, 8.00000000e+01, 8.00000000e+01, 8.00000000e+01, 8.00000000e+01], [ 1.62000000e+02, 1.62000000e+02, 1.62000000e+02, 1.62000000e+02, 1.62000000e+02, 1.62000000e+02]]])