MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / load_and_map_checkpoint

Function load_and_map_checkpoint

rat-sql-gap/seq2struct/utils/saver.py:45–53  ·  view source on GitHub ↗
(model, model_dir, remap)

Source from the content-addressed store, hash-verified

43
44
45def load_and_map_checkpoint(model, model_dir, remap):
46 path = os.path.join(model_dir, 'model_checkpoint')
47 print("Loading parameters %s from %s" % (remap.keys(), model_dir))
48 checkpoint = torch.load(path)
49 new_state_dict = model.state_dict()
50 for name, value in remap.items():
51 # TODO: smarter mapping.
52 new_state_dict[name] = checkpoint['model'][value]
53 model.load_state_dict(new_state_dict)
54
55
56def save_checkpoint(items, step, model_dir, ignore=[],

Callers 1

restore_partMethod · 0.85

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected