diff --git a/ppdet/utils/checkpoint.py b/ppdet/utils/checkpoint.py index cf107e0fd6862ffc9809e5f453526ec0e52a2e71..ffe475dfa37d3823234c50ac10741718027444f8 100644 --- a/ppdet/utils/checkpoint.py +++ b/ppdet/utils/checkpoint.py @@ -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