我尝试冻结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!发布于 2018-01-23 10:59:03
您应该按如下方式加载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://stackoverflow.com/questions/48389582
复制相似问题