Tensorflow:打印图节点

时间:2019-05-27 09:57:39

标签: python tensorflow

这两种方法之间的打印图形节点有什么区别? 似乎操作的打印顺序不同。

def print_graph_v1():
    with open(input_model_filepath, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())

        for node in graph_def.node:
            print('-'*60)
            print(node.name)

def print_graph_v2():
    with tf.gfile.GFile(input_model_filepath, "rb") as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())

    with tf.Graph().as_default() as graph:
        tf.import_graph_def(graph_def, name='')

    for op in graph.get_operations():
        print('-' * 60)
        print(op.name)

0 个答案:

没有答案