diff --git a/python/paddle/tensor/stat.py b/python/paddle/tensor/stat.py index 6c4fd2c2a4b4689ac0c2d5ed289bca605f3797ef..9bde154bfe08f1df2adbacd077d074e3c52e7db0 100644 --- a/python/paddle/tensor/stat.py +++ b/python/paddle/tensor/stat.py @@ -182,6 +182,7 @@ def var(x, axis=None, unbiased=True, keepdim=False, name=None): if unbiased: one_const = paddle.ones([1], x.dtype) n = where(n > one_const, n - 1.0, one_const) + n.stop_gradient = True out /= n return out