Writes Numpy array to TF checkpoint.
(var_name, array, checkpoint_path)
| 88 | |
| 89 | |
| 90 | def 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 | |
| 102 | def main(_): |