From 63f573ad336464779141c0aa8855ef85318c672e Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Tue, 12 Apr 2022 16:53:02 +0800 Subject: [PATCH] [Eager]Fix clear_gradient bug in optimizer (#41658) (#41676) --- python/paddle/optimizer/optimizer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/paddle/optimizer/optimizer.py b/python/paddle/optimizer/optimizer.py index 36b773ac285..0af8b8bb894 100644 --- a/python/paddle/optimizer/optimizer.py +++ b/python/paddle/optimizer/optimizer.py @@ -1112,8 +1112,7 @@ class Optimizer(object): if _in_eager_without_dygraph_check(): for p in param_list: - clear_func = p._zero_grads if set_to_zero else p.clear_gradient - clear_func() + p.clear_gradient(set_to_zero) else: core.clear_gradients(param_list, set_to_zero) -- GitLab