TensorFlow函數教程:tf.io.write_graph

2019-02-27 17:27 更新

tf.io.write_graph函數

別名:

  • tf.io.write_graph
  • tf.train.write_graph
tf.io.write_graph(
    graph_or_graph_def,
    logdir,
    name,
    as_text=True
)

定義在:tensorflow/python/framework/graph_io.py。

將圖形原型寫入文件。

除非as_text是False,否則該圖形將被寫為文本原型。

v = tf.Variable(0, name='my_variable')
sess = tf.Session()
tf.train.write_graph(sess.graph_def, '/tmp/my-model', 'train.pbtxt')

或者:

v = tf.Variable(0, name='my_variable')
sess = tf.Session()
tf.train.write_graph(sess.graph, '/tmp/my-model', 'train.pbtxt')

參數:

  • graph_or_graph_def:Graph或GraphDef協議緩沖區(qū)。
  • logdir:寫入圖形的目錄。這可以指遠程文件系統,例如Google Cloud Storage(GCS)。
  • name:圖形的文件名。
  • as_text:如果為True,將圖形寫為ASCII原型。

返回:

輸出原型文件的路徑。

以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號