[Tensorflow]-[技術]Tensorflow訓練好的模型的保存和讀取
03-04
pb格式:
保存為pb格式主要有兩種方式:
- 第一種方式使用graph_util.convert_variables_to_constants()
from tensorflow.python.framework import graph_utilconstant_graph = graph_util.convert_variables_to_constants(sess,sess.graph_def,[graph的名字])with tf.gfile.FastGFile(model.pb,mode=wb) as f: f.write(constant_graph.SerializeToString())
2.第二種方式使用tf.get_default_graph().as_graph_def()
constant_graph = tf.get_default_graph().as_graph_def()with tf.gfile.FastGFile(model.pb,mode=wb) as f: f.write(constant_graph.SerializeToString())
推薦閱讀:
※把故宮裝進手機,讓柯潔走向最強!谷歌在北京秀出四個AI商用大招
※學習筆記TF040:多GPU並行
※如何評價deep mind開源的sonnet?
※譯文 | 簡明 TensorFlow 教程:所有的模型
※怎樣使用tensorflow導入已經下載好的mnist數據集?
TAG:TensorFlow |
