提交 c7cca0a6 编写于 作者: M minqiyang

Fix auto growth bug of optimizer in dygraph mode

test=release/1.4
上级 ab6600e1
...@@ -275,6 +275,17 @@ class Optimizer(object): ...@@ -275,6 +275,17 @@ class Optimizer(object):
self._create_global_learning_rate() self._create_global_learning_rate()
optimize_ops = [] optimize_ops = []
if framework._in_dygraph_mode():
for param_and_grad in parameters_and_grads:
if param_and_grad[1] is None:
continue
with param_and_grad[0].block.program._optimized_guard(
param_and_grad):
if param_and_grad[0].trainable is True:
optimize_op = self._append_optimize_op(global_block,
param_and_grad)
optimize_ops.append(optimize_op)
else:
for param_and_grad in parameters_and_grads: for param_and_grad in parameters_and_grads:
if param_and_grad[1] is None: if param_and_grad[1] is None:
continue continue
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册