MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / init_from_ckpt

Method init_from_ckpt

sat/vae_modules/autoencoder.py:75–86  ·  view source on GitHub ↗
(self, path, ignore_keys=list())

Source from the content-addressed store, hash-verified

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:

Callers 1

apply_ckptMethod · 0.95

Calls 3

printFunction · 0.50
loadMethod · 0.45
load_state_dictMethod · 0.45

Tested by

no test coverage detected