mindspore.mint.std_mean
- mindspore.mint.std_mean(input, dim=None, *, correction=1, keepdim=False)[source]
By default, return the standard deviation and mean of each dimension in Tensor. If dim is a dimension list, calculate the standard deviation and mean of the corresponding dimension.
The standard deviation (
) is calculated as:where is
the sample set of elements, is the sample mean, is the number of samples and is the correction .Warning
This is an experimental API that is subject to change or deletion.
- Parameters
- Keyword Arguments
correction (int, optional) – Difference between the sample size and sample degrees of freedom. Defaults to Bessel's correction. Default:
1
.keepdim (bool, optional) – Whether to preserve the dimensions of the output Tensor. If True, retain the reduced dimension with a size of 1. Otherwise, remove the dimensions. Default value:
False
.
- Returns
A tuple of standard deviation and mean.
- Raises
TypeError – If input is not a Tensor.
TypeError – If dim is not one of the following data types: int, tuple, list, or Tensor.
TypeError – If keepdim is not a bool.
ValueError – If dim is out of range.
- Supported Platforms:
Ascend
Examples
>>> import mindspore as ms >>> input = ms.Tensor([[1, 2, 3, 4], [-1, 1, 4, -10]], ms.float32) >>> output_std, output_mean = ms.mint.std_mean(input, 1, correction=2, keepdim=True) >>> print(output_std) [[1.5811388] [7.3824115]] >>> print(output_mean) [[ 2.5] [-1.5]]