Update utils.py

This commit is contained in:
Stardust·减
2023-08-25 20:59:46 +08:00
committed by GitHub
parent 9711fe5ea8
commit 7934ba6aba

View File

@@ -22,8 +22,8 @@ def load_checkpoint(checkpoint_path, model, optimizer=None, skip_optimizer=False
learning_rate = checkpoint_dict['learning_rate']
if optimizer is not None and not skip_optimizer and checkpoint_dict['optimizer'] is not None:
optimizer.load_state_dict(checkpoint_dict['optimizer'])
elif optimizer is None and not skip_optimizer: #Disable this line if Infer ,and enable the line below
#else:
elif optimizer is None and not skip_optimizer:
#else: #Disable this line if Infer ,and enable the line upper
new_opt_dict = optimizer.state_dict()
new_opt_dict_params = new_opt_dict['param_groups'][0]['params']
new_opt_dict['param_groups'] = checkpoint_dict['optimizer']['param_groups']