【问题标题】:Unable to open table file ./model/checkpoint:无法打开表文件 ./model/checkpoint:
【发布时间】:2018-01-23 10:59:03
【问题描述】:

我尝试冻结在 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!

【问题讨论】:

    标签: tensorflow


    【解决方案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

    【讨论】:

      猜你喜欢
      • 2019-01-06
      • 1970-01-01
      • 2013-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-09
      • 2018-11-30
      • 2015-10-16
      相关资源
      最近更新 更多