MCPcopy Create free account
hub / github.com/InternScience/InternAgent / load_model

Function load_model

tasks/AutoMolecule3D/code/experiment.py:528–542  ·  view source on GitHub ↗
(filepath, args=None, device="cpu", **kwargs)

Source from the content-addressed store, hash-verified

526
527
528def load_model(filepath, args=None, device="cpu", **kwargs):
529 ckpt = torch.load(filepath, map_location="cpu")
530 if args is None:
531 args = ckpt["hyper_parameters"]
532
533 for key, value in kwargs.items():
534 if not key in args:
535 rank_zero_warn(f"Unknown hyperparameter: {key}={value}")
536 args[key] = value
537
538 model = create_model(args)
539 state_dict = {re.sub(r"^model\.", "", k): v for k, v in ckpt["state_dict"].items()}
540 model.load_state_dict(state_dict)
541
542 return model.to(device)
543
544
545class ViSNet(nn.Module):

Callers 1

__init__Method · 0.85

Calls 5

create_modelFunction · 0.85
loadMethod · 0.45
itemsMethod · 0.45
subMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected