Skip to content

Commit a32e98b

Browse files
allenye0119soumith
authored andcommitted
Add documentation for std/var unbiased argument (pytorch#2509)
1 parent de24bb4 commit a32e98b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

torch/_torch_docs.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4069,12 +4069,16 @@
40694069

40704070
add_docstr(torch._C.std,
40714071
"""
4072-
.. function:: std(input) -> float
4072+
.. function:: std(input, unbiased=True) -> float
40734073
40744074
Returns the standard-deviation of all elements in the :attr:`input` Tensor.
40754075
4076+
If :attr:`unbiased` is false, then the standard-deviation will be calculated via
4077+
the biased estimator. Otherwise, Bessel's correction will be used.
4078+
40764079
Args:
40774080
input (Tensor): the input `Tensor`
4081+
unbiased (bool): whether to use the unbiased estimation or not
40784082
40794083
Example::
40804084
@@ -4088,7 +4092,7 @@
40884092
1.3782334731508061
40894093
40904094
4091-
.. function:: std(input, dim, keepdim=False, out=None) -> Tensor
4095+
.. function:: std(input, dim, keepdim=False, unbiased=True, out=None) -> Tensor
40924096
40934097
Returns the standard-deviation of each row of the :attr:`input` Tensor in the
40944098
given dimension :attr:`dim`.
@@ -4098,10 +4102,14 @@
40984102
Otherwise, :attr:`dim` is squeezed (see :func:`torch.squeeze`), resulting
40994103
in the output Tensor having 1 fewer dimension than :attr:`input`.
41004104
4105+
If :attr:`unbiased` is false, then the standard-deviation will be calculated via
4106+
the biased estimator. Otherwise, Bessel's correction will be used.
4107+
41014108
Args:
41024109
input (Tensor): the input `Tensor`
41034110
dim (int): the dimension to reduce
41044111
keepdim (bool): whether the output Tensor has :attr:`dim` retained or not
4112+
unbiased (bool): whether to use the unbiased estimation or not
41054113
out (Tensor, optional): the result Tensor
41064114
41074115
Example::
@@ -4709,12 +4717,16 @@
47094717

47104718
add_docstr(torch._C.var,
47114719
"""
4712-
.. function:: var(input) -> float
4720+
.. function:: var(input, unbiased=True) -> float
47134721
47144722
Returns the variance of all elements in the :attr:`input` Tensor.
47154723
4724+
If :attr:`unbiased` is false, then the variance will be calculated via the
4725+
biased estimator. Otherwise, Bessel's correction will be used.
4726+
47164727
Args:
47174728
input (Tensor): the input `Tensor`
4729+
unbiased (bool): whether to use the unbiased estimation or not
47184730
47194731
Example::
47204732
@@ -4728,7 +4740,7 @@
47284740
1.899527506513334
47294741
47304742
4731-
.. function:: var(input, dim, keepdim=False, out=None) -> Tensor
4743+
.. function:: var(input, dim, keepdim=False, unbiased=True, out=None) -> Tensor
47324744
47334745
Returns the variance of each row of the :attr:`input` Tensor in the given
47344746
dimension :attr:`dim`.
@@ -4738,10 +4750,14 @@
47384750
Otherwise, :attr:`dim` is squeezed (see :func:`torch.squeeze`), resulting in
47394751
the outputs Tensor having 1 fewer dimension than :attr:`input`.
47404752
4753+
If :attr:`unbiased` is false, then the variance will be calculated via the
4754+
biased estimator. Otherwise, Bessel's correction will be used.
4755+
47414756
Args:
47424757
input (Tensor): the input `Tensor`
47434758
dim (int): the dimension to reduce
47444759
keepdim (bool): whether the output Tensor has :attr:`dim` retained or not
4760+
unbiased (bool): whether to use the unbiased estimation or not
47454761
out (Tensor, optional): the result Tensor
47464762
47474763
Example::

0 commit comments

Comments
 (0)