torch.var¶
-
torch.var(input, unbiased=True) → Tensor¶ Returns the variance of all elements in the
inputtensor.If
unbiasedisFalse, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.- Parameters
Example:
>>> a = torch.randn(1, 3) >>> a tensor([[-0.3425, -1.2636, -0.4864]]) >>> torch.var(a) tensor(0.2455)
-
torch.var(input, dim, keepdim=False, unbiased=True, out=None) → Tensor
Returns the variance of each row of the
inputtensor in the given dimensiondim.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).If
unbiasedisFalse, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.- Parameters
Example:
>>> a = torch.randn(4, 4) >>> a tensor([[-0.3567, 1.7385, -1.3042, 0.7423], [ 1.3436, -0.1015, -0.9834, -0.8438], [ 0.6056, 0.1089, -0.3112, -1.4085], [-0.7700, 0.6074, -0.1469, 0.7777]]) >>> torch.var(a, 1) tensor([ 1.7444, 1.1363, 0.7356, 0.5112])