Skip to content

Commit 63f573a

Browse files
authored
[Eager]Fix clear_gradient bug in optimizer (#41658) (#41676)
1 parent 6a1ddd6 commit 63f573a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

python/paddle/optimizer/optimizer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,7 @@ def clear_grad(self, set_to_zero=True):
11121112

11131113
if _in_eager_without_dygraph_check():
11141114
for p in param_list:
1115-
clear_func = p._zero_grads if set_to_zero else p.clear_gradient
1116-
clear_func()
1115+
p.clear_gradient(set_to_zero)
11171116
else:
11181117
core.clear_gradients(param_list, set_to_zero)
11191118

0 commit comments

Comments
 (0)