首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法打开表文件。/model/checkpoint:

无法打开表文件。/model/checkpoint:
EN

Stack Overflow用户
提问于 2018-01-23 04:16:46
回答 1查看 909关注 0票数 0

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

模型在/tmp/iris_ model中生成文件:

代码语言:javascript
复制
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源代码中的工具冻结模型时,我得到了这个错误:

代码语言:javascript
复制
python3 ./tensorflow/tensorflow/python/tools/freeze_graph.py /tmp/iris_model checkpoint '' doesn't exist!
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-23 10:59:03

您应该按如下方式加载model.ckpt-10.data-00000-of-00001

代码语言:javascript
复制
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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48389582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档