Shortcuts

torch.var_mean

torch.var_mean(input, dim, unbiased, keepdim=False, *, out=None)

If unbiased is True, Bessel’s correction will be used to calculate the variance. Otherwise, the sample variance is calculated, without any correction.

Parameters:
  • input (Tensor) – the input tensor.

  • dim (int or tuple of ints, optional) – the dimension or dimensions to reduce. If None, all dimensions are reduced.

Keyword Arguments:
  • unbiased (bool) – whether to use Bessel’s correction (δN=1\delta N = 1).

  • keepdim (bool) – whether the output tensor has dim retained or not.

  • out (Tensor, optional) – the output tensor.

Returns:

A tuple (var, mean) containing the variance and mean.

torch.var_mean(input, unbiased)

Calculates the variance and mean of all elements in the input tensor.

If unbiased is True, Bessel’s correction will be used. Otherwise, the sample deviation is calculated, without any correction.

Parameters:
  • input (Tensor) – the input tensor.

  • unbiased (bool) – whether to use Bessel’s correction (δN=1\delta N = 1).

Returns:

A tuple (var, mean) containing the variance and mean.

Example:

>>> a = torch.tensor([[-0.8166, -1.3802, -0.3560]])
>>> torch.var_mean(a, unbiased=False)
(tensor(0.1754), tensor(-0.8509))

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources