【发布时间】:2016-05-22 23:06:24
【问题描述】:
基于此converting-trained-tensorflow-model-to-protobuf 我正在尝试保存/恢复 TF 图但没有成功。
这是保护程序:
with tf.Graph().as_default():
variable_node = tf.Variable(1.0, name="variable_node")
output_node = tf.mul(variable_node, 2.0, name="output_node")
sess = tf.Session()
init = tf.initialize_all_variables()
sess.run(init)
output = sess.run(output_node)
tf.train.write_graph(sess.graph.as_graph_def(), summ_dir, 'model_00_g.pbtxt', as_text=True)
#self.assertNear(2.0, output, 0.00001)
saver = tf.train.Saver()
saver.save(sess, saver_path)
生成带有文本图形描述的model_00_g.pbtxt。几乎从freeze_graph_test.py复制粘贴。
这里是读者:
with tf.Session() as sess:
with tf.Graph().as_default():
graph_def = tf.GraphDef()
graph_path = '/mnt/code/test_00/log/2016-02-11.22-37-46/model_00_g.pbtxt'
with open(graph_path, "rb") as f:
proto_b = f.read()
#print proto_b # -> I can see it
graph_def.ParseFromString(proto_b) # no luck..
_ = tf.import_graph_def(graph_def, name="")
print sess.graph_def
在graph_def.ParseFromString() 与DecodeError: Tag had invalid wire type. 失败
我在 docker 容器 b.gcr.io/tensorflow/tensorflow:latest-devel 上,以防万一。
【问题讨论】:
标签: tensorflow