| 259 | |
| 260 | |
| 261 | def load_checkpoint(checkpoint_file, model, optimizer, lr): |
| 262 | print("=> Loading checkpoint") |
| 263 | checkpoint = torch.load(checkpoint_file, map_location="cuda") |
| 264 | model.load_state_dict(checkpoint["state_dict"]) |
| 265 | optimizer.load_state_dict(checkpoint["optimizer"]) |
| 266 | |
| 267 | # If we don't do this then it will just have learning rate of old checkpoint |
| 268 | # and it will lead to many hours of debugging \: |
| 269 | for param_group in optimizer.param_groups: |
| 270 | param_group["lr"] = lr |
| 271 | |
| 272 | def seed_everything(seed=42): |
| 273 | os.environ['PYTHONHASHSEED'] = str(seed) |