未验证 提交 c448032b 编写于 作者: A Aurelius84 提交者: GitHub

[Eager]Fix clear_gradient bug in optimizer (#41658)

上级 59ec9599
...@@ -1112,8 +1112,7 @@ class Optimizer(object): ...@@ -1112,8 +1112,7 @@ class Optimizer(object):
if _in_eager_without_dygraph_check(): if _in_eager_without_dygraph_check():
for p in param_list: for p in param_list:
clear_func = p._zero_grads if set_to_zero else p.clear_gradient p.clear_gradient(set_to_zero)
clear_func()
else: else:
core.clear_gradients(param_list, set_to_zero) core.clear_gradients(param_list, set_to_zero)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册