From 32059d22fb5e6e81433e555bbaedb3371420a37f Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Sun, 29 Jan 2023 20:03:54 +0800 Subject: [PATCH] fix paddle.var stop_gradient error --- python/paddle/tensor/stat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/paddle/tensor/stat.py b/python/paddle/tensor/stat.py index 6c4fd2c2a4b..9bde154bfe0 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 -- GitLab