torch / torch
torch.var¶
-
torch.
var
(input, unbiased=True) → Tensor¶ Returns the variance of all elements in the
input
tensor.If
unbiased
isFalse
, 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, unbiased=True, keepdim=False, *, out=None) → Tensor
Returns the variance of each row of the
input
tensor in the given dimensiondim
.If
keepdim
isTrue
, the output tensor is of the same size asinput
except in the dimension(s)dim
where it is of size 1. Otherwise,dim
is squeezed (seetorch.squeeze()
), resulting in the output tensor having 1 (orlen(dim)
) fewer dimension(s).If
unbiased
isFalse
, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.- Parameters
- Keyword Arguments
out (Tensor, optional) – the output tensor.
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])
此页内容是否对您有帮助