Skip to content

Commit

Permalink
[Eager]Fix clear_gradient bug in optimizer (#41658)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelius84 authored Apr 12, 2022
1 parent 59ec959 commit c448032
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions python/paddle/optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,7 @@ def clear_grad(self, set_to_zero=True):

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)

Expand Down

0 comments on commit c448032

Please sign in to comment.