You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/paddle/tensor/stat.py
+46-16Lines changed: 46 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,10 @@
32
32
33
33
from ..base.data_feederimportcheck_type, check_variable_and_dtype
34
34
from ..common_ops_importimportVariable
35
-
from ..frameworkimportLayerHelper, core
35
+
from ..frameworkimport (
36
+
LayerHelper,
37
+
core,
38
+
)
36
39
from .mathimport_get_reduce_axis_with_tensor
37
40
38
41
ifTYPE_CHECKING:
@@ -157,9 +160,12 @@ def mean(
157
160
defvar(
158
161
x: Tensor,
159
162
axis: int|Sequence[int] |None=None,
160
-
unbiased: bool=True,
163
+
unbiased: bool|None=None,
161
164
keepdim: bool=False,
162
165
name: str|None=None,
166
+
*,
167
+
correction: float=1,
168
+
out: Tensor|None=None,
163
169
) ->Tensor:
164
170
"""
165
171
Computes the variance of ``x`` along ``axis`` .
@@ -181,6 +187,9 @@ def var(
181
187
unbiased (bool, optional): Whether to use the unbiased estimation. If ``unbiased`` is True, the divisor used in the computation is :math:`N - 1`, where :math:`N` represents the number of elements along ``axis`` , otherwise the divisor is :math:`N`. Default is True.
182
188
keep_dim (bool, optional): Whether to reserve the reduced dimension in the output Tensor. The result tensor will have one fewer dimension than the input unless keep_dim is true. Default is False.
183
189
name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
190
+
correction (int|float, optional): Difference between the sample size and sample degrees of freedom.
191
+
Defaults to 1 (Bessel's correction). If unbiased is specified, this parameter is ignored.
192
+
out (Tensor|None, optional): Output tensor. Default is None.
184
193
185
194
Returns:
186
195
Tensor, results of variance along ``axis`` of ``x``, with the same data type as ``x``.
@@ -198,28 +207,41 @@ def var(
198
207
>>> print(out2.numpy())
199
208
[1. 4.3333335]
200
209
"""
210
+
ifunbiasedisnotNoneandcorrection!=1:
211
+
raiseValueError("Only one of unbiased and correction may be given")
0 commit comments