From c448032bc894ffae90a2c962e1f8a1c640a08c81 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Tue, 12 Apr 2022 10:51:10 +0800 Subject: [PATCH] [Eager]Fix clear_gradient bug in optimizer (#41658) --- 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