Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#1198 from will-jl944/2.0_bug_fix
Browse files Browse the repository at this point in the history
[cherry-pick] fix resume checkpoint bug
  • Loading branch information
will-jl944 authored Oct 11, 2021
2 parents 3ea22be + ba6df9c commit bf1ef28
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions paddlex/utils/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ def load_pretrain_weights(model, pretrain_weights=None, model_name=None):
def load_optimizer(optimizer, state_dict_path):
logging.info("Loading optimizer from {}".format(state_dict_path))
optim_state_dict = paddle.load(state_dict_path)
for key in optimizer.state_dict().keys():
if key not in optim_state_dict.keys():
optim_state_dict[key] = optimizer.state_dict()[key]
if 'last_epoch' in optim_state_dict:
optim_state_dict.pop('last_epoch')
optimizer.set_state_dict(optim_state_dict)
Expand Down

0 comments on commit bf1ef28

Please sign in to comment.