(checkpoint_file, model, optimizer, lr)
| 39 | |
| 40 | |
| 41 | def load_checkpoint(checkpoint_file, model, optimizer, lr): |
| 42 | print("=> Loading checkpoint") |
| 43 | checkpoint = torch.load(checkpoint_file, map_location=config.DEVICE) |
| 44 | model.load_state_dict(checkpoint["state_dict"]) |
| 45 | optimizer.load_state_dict(checkpoint["optimizer"]) |
| 46 | |
| 47 | # If we don't do this then it will just have learning rate of old checkpoint |
| 48 | # and it will lead to many hours of debugging \: |
| 49 | for param_group in optimizer.param_groups: |
| 50 | param_group["lr"] = lr |