# Create some variables.
v1 = tf.Variable(..., name="v1")
v2 = tf.Variable(..., name="v2")
...
# Add an op to initialize the variables.
init_op = tf.initialize_all_variables()
# Add ops to save and restore all the variables.
saver = tf.train.Saver()
# Later, launch the model, initialize the variables, do some work, save the
# variables to disk.
with tf.Session() as sess:
sess.run(init_op)
# Do some work with the model.
..
# Save the variables to disk.
save_path = saver.save(sess, "/tmp/model.ckpt")
print("Model saved in file: %s" % save_path)
下面是tf.variable docs中的代码示例,可以说明:
所以我遇到了同样的问题(估计器还没有保存/恢复功能)。我尝试了savers和^{} 来尝试保存检查点,但结果发现这要简单得多;在实例化估计器时只需指定
model_dir
。这将自动保存检查点,这些检查点可以通过创建具有相同model_dir
的估计器来恢复。估计器文档here。在感谢@ilblackdragon提供的解决方案here。在
相关问题 更多 >
编程相关推荐