mindspore.ops.std
- mindspore.ops.std(input_x, axis=(), unbiased=True, keep_dims=False)[source]
Returns the standard-deviation and mean of each row of the input tensor in the dimension axis. If axis is a list of dimensions, reduce over all of them.
- Parameters
input_x (Tensor[Number]) – Input tensor.
axis (Union[int, tuple(int), list(int)]) – The dimensions to reduce. Default: (), reduce all dimensions. Only constant value is allowed. Must be in the range [-rank(input_x), rank(input_x)).
unbiased (bool) – Whether to use Bessel’s correction. If true, will use the Bessel correction unbiased estimation. If false, will through the biased estimation to calculate the standard deviation.
keep_dims (bool) – Whether the output tensor has dim retained or not. If true, keep these reduced dimensions and the length is 1. If false, don’t keep these dimensions.
- Returns
A tuple (output_std, output_mean) containing the standard deviation and mean.
- Raises
TypeError – If input_x is not a Tensor.
TypeError – If axis is not one of the following: int, tuple or list.
TypeError – If keep_dims is not a bool.
ValueError – If axis is out of range.
- Supported Platforms:
Ascend
CPU
Examples
>>> import mindspore.ops as ops >>> input_x = Tensor(np.array([[1, 2, 3], [-1, 1, 4]]).astype(np.float32)) >>> output = ops.std(input_x, 1, True, False) >>> output_std, output_mean = output[0], output[1] >>> print(output_std) [1. 2.5166116] >>> print(output_mean) [2. 1.3333334]