未验证 提交 f545a541 编写于 作者: C cnn 提交者: GitHub

[Dygraph] solve load optimizer if some key not in optimizer (#1812)

* solve load optimizer if some key not in optimizer

* variable name tmp_key to key

* add comment
上级 d1ce58ca
......@@ -92,6 +92,10 @@ def load_weight(model, weight, optimizer=None):
if optimizer is not None and os.path.exists(path + '.pdopt'):
optim_state_dict = paddle.load(path + '.pdopt')
# to slove resume bug, will it be fixed in paddle 2.0
for key in optimizer.state_dict().keys():
if not key in optim_state_dict.keys():
optim_state_dict[key] = optimizer.state_dict()[key]
optimizer.set_state_dict(optim_state_dict)
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册