(self, path)
| 37 | torch.save(val.state_dict(), os.path.join(path, f"{key}.pth")) |
| 38 | |
| 39 | def load(self, path): |
| 40 | logging.info(f"load from {path}") |
| 41 | self.step = torch.load(os.path.join(path, "step.pth")) |
| 42 | for key, val in self.__dict__.items(): |
| 43 | if key != "step" and val is not None: |
| 44 | val.load_state_dict( |
| 45 | torch.load(os.path.join(path, f"{key}.pth"), map_location="cpu") |
| 46 | ) |
| 47 | |
| 48 | def resume(self, ckpt_root, step=None): |
| 49 | if not os.path.exists(ckpt_root): |
no outgoing calls