最佳答案
在阅读了 医生之后,我在 TensorFlow
中保存了一个模型,下面是我的演示代码:
# Create some variables.
v1 = tf.Variable(..., name="v1")
v2 = tf.Variable(..., name="v2")
...
# Add an op to initialize the variables.
init_op = tf.global_variables_initializer()
# 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)
但在那之后,我发现有3个文件
model.ckpt.data-00000-of-00001
model.ckpt.index
model.ckpt.meta
我不能通过恢复 model.ckpt
文件来恢复模型,因为没有这样的文件。这是我的密码
with tf.Session() as sess:
# Restore variables from disk.
saver.restore(sess, "/tmp/model.ckpt")
那为什么有三份文件?