(self, path, ignore_keys=list())
| 73 | self.init_from_ckpt(ckpt) |
| 74 | |
| 75 | def init_from_ckpt(self, path, ignore_keys=list()): |
| 76 | sd = torch.load(path, map_location="cpu")["state_dict"] |
| 77 | keys = list(sd.keys()) |
| 78 | for k in keys: |
| 79 | for ik in ignore_keys: |
| 80 | if k.startswith(ik): |
| 81 | print("Deleting key {} from state_dict.".format(k)) |
| 82 | del sd[k] |
| 83 | missing_keys, unexpected_keys = self.load_state_dict(sd, strict=False) |
| 84 | print("Missing keys: ", missing_keys) |
| 85 | print("Unexpected keys: ", unexpected_keys) |
| 86 | print(f"Restored from {path}") |
| 87 | |
| 88 | @abstractmethod |
| 89 | def get_input(self, batch) -> Any: |
no test coverage detected