MCPcopy
hub / github.com/jaymody/picoGPT / set_in_nested_dict

Function set_in_nested_dict

utils.py:45–51  ·  view source on GitHub ↗
(d, keys, val)

Source from the content-addressed store, hash-verified

43
44def load_gpt2_params_from_tf_ckpt(tf_ckpt_path, hparams):
45 def set_in_nested_dict(d, keys, val):
46 if not keys:
47 return val
48 if keys[0] not in d:
49 d[keys[0]] = {}
50 d[keys[0]] = set_in_nested_dict(d[keys[0]], keys[1:], val)
51 return d
52
53 params = {"blocks": [{} for _ in range(hparams["n_layer"])]}
54 for name, _ in tf.train.list_variables(tf_ckpt_path):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected