阅读(1214) (1)

TensorFlow函数教程:tf.io.write_graph

2019-02-27 13:44:46 更新

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协议缓冲区。
  • logdir:写入图形的目录。这可以指远程文件系统,例如Google Cloud Storage(GCS)。
  • name:图形的文件名。
  • as_text:如果为True,将图形写为ASCII原型。

返回:

输出原型文件的路径。