ValueError:传递的save_path不是有效的检查点:modeltest.ckpt

时间:2018-09-21 09:20:46

标签: python tensorflow

我运行此代码

tf.reset_default_graph()
v1 = tf.Variable(tf.constant(0.1, shape = [2]), name="v1")
v2 = tf.Variable(tf.constant(0.2, shape = [2]), name="v2")
saver = tf.train.Saver()
with tf.Session() as sess:
    saver.restore(sess, "/tmp/model/model.ckpt")

然后发生此错误:ValueError:传递的save_path不是有效的检查点:modeltest.ckpt

这是我的环境:

tensorflow(1.10.1)

张量板(1.10.0)

h5py(2.8.0)

Python 3.6.5

请问如何解决此错误

谢谢

1 个答案:

答案 0 :(得分:0)

If the model name is "modeltest.ckpt", then you probably have the model in a zip file (modeltest.zip). Then you need to extract the model into a folder (named "model\" for example) and it will include 3 files. Now you can use the name as follows: "model\modeltest.ckpt"