On this page
torch.std_mean
- torch.std_mean(input, dim=None, *, correction=1, keepdim=False, out=None)
- 
    Calculates the standard deviation and mean over the dimensions specified by dim.dimcan be a single dimension, list of dimensions, orNoneto reduce over all dimensions.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.If keepdimisTrue, the output tensor is of the same size asinputexcept in the dimension(s)dimwhere it is of size 1. Otherwise,dimis squeezed (seetorch.squeeze()), resulting in the output tensor having 1 (orlen(dim)) fewer dimension(s).- Parameters
- Keyword Arguments
- 
      - correction (int) – - difference between the sample size and sample degrees of freedom. Defaults to Bessel’s correction, - correction=1.- Changed in version 2.0: Previously this argument was called - unbiasedand was a boolean with- Truecorresponding to- correction=1and- Falsebeing- correction=0.
- keepdim (bool) – whether the output tensor has dimretained or not.
- out (Tensor, optional) – the output tensor.
 
- Returns
- 
      A tuple (std, mean) containing the standard deviation and mean. 
 Example>>> a = torch.tensor( ... [[ 0.2035, 1.2959, 1.8101, -0.4644], ... [ 1.5027, -0.3270, 0.5905, 0.6538], ... [-1.5745, 1.3330, -0.5596, -0.6548], ... [ 0.1264, -0.5080, 1.6420, 0.1992]]) >>> torch.std_mean(a, dim=0, keepdim=True) (tensor([[1.2620, 1.0028, 1.0957, 0.6038]]), tensor([[ 0.0645, 0.4485, 0.8707, -0.0665]]))
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
 https://pytorch.org/docs/2.1/generated/torch.std_mean.html