Tensorflow附带的Android示例下载了InceptionV3的protobuf文件,其中包含图表和模型中的值。在文档中,我只能找到如何序列化图表(tf.Graph.as_graph_def
)或使用tf.train.Saver
保存变量值。如何将所有内容保存到单个文件中,如同该示例所做的那样?
答案 0 :(得分:4)
我在这个主题上回答了类似的问题:Is there an example on how to generate protobuf files holding trained Tensorflow graphs?
基本思路是使用tf.import_graph_def()
用常量替换原始(训练)图中的变量,然后使用tf.Graph.as_graph_def()
写出结果GraphDef
。