MCPcopy Create free account
hub / github.com/google-research/language / write_array_to_checkpoint

Function write_array_to_checkpoint

language/realm/refresh_doc_embeds.py:90–99  ·  view source on GitHub ↗

Writes Numpy array to TF checkpoint.

(var_name, array, checkpoint_path)

Source from the content-addressed store, hash-verified

88
89
90def write_array_to_checkpoint(var_name, array, checkpoint_path):
91 """Writes Numpy array to TF checkpoint."""
92 with tf.Graph().as_default():
93 init_value = tf.py_func(lambda: array, [], tf.float32)
94 init_value.set_shape(array.shape)
95 var = tf.get_variable(var_name, initializer=init_value)
96 saver = tf.train.Saver([var])
97 with tf.Session() as session:
98 session.run(tf.global_variables_initializer())
99 saver.save(session, checkpoint_path)
100
101
102def main(_):

Callers 1

mainFunction · 0.70

Calls 2

runMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…