无法打开表文件./model/checkpoint:

时间:2018-01-22 20:16:46

标签: tensorflow

我尝试在tensorflow教程中冻结模型生成: https://www.tensorflow.org/get_started/estimator

模型在/ tmp / iris_model:

中生成文件
checkpoint
eval
events.out.tfevents.1516649318.xavier-OMEN-by-HP-Laptop
graph.pbtxt
model.ckpt-10.data-00000-of-00001
model.ckpt-10.index
model.ckpt-10.meta
model.ckpt-1.data-00000-of-00001
model.ckpt-1.index
model.ckpt-1.meta

当我尝试使用tensorflow源中的工具冻结模型时,我得到了错误:

python3 ./tensorflow/tensorflow/python/tools/freeze_graph.py /tmp/iris_model checkpoint '' doesn't exist!

1 个答案:

答案 0 :(得分:1)

你应该加载model.ckpt-10.data-00000-of-00001

tf.reset_default_graph()

# Create some variables.
v1 = tf.get_variable("v1", shape=[3])
v2 = tf.get_variable("v2", shape=[5])

# Add ops to save and restore all the variables.
saver = tf.train.Saver()

# Later, launch the model, use the saver to restore variables from disk, and
# do some work with the model.
with tf.Session() as sess:
  # Restore variables from disk.
  saver.restore(sess, "/your/path/model.ckpt-10.data-00000-of-00001")
  print("Model restored.")
  # Check the values of the variables
  print("v1 : %s" % v1.eval())
  print("v2 : %s" % v2.eval())

上面的代码是从TF文档复制的:

https://www.tensorflow.org/programmers_guide/saved_model