繁体   English   中英

如何在tensorflow中找到给定.ckpt.meta文件的输出节点名称

[英]How to find the output node name of given .ckpt.meta file in tensorflow

到目前为止,我可以得到给定任何 .ckpt.meta 文件的所有节点名称的列表,但我想知道是否有系统的方法可以从列表中找出输出节点名称。

import tensorflow as tf

tf.reset_default_graph()
with tf.Session() as sess:
    saver = tf.train.import_meta_graph('mymodel.ckpt.meta')
    graph_def = tf.get_default_graph().as_graph_def()
    node_list=[n.name for n in graph_def.node]

你可以试试:

[n.name for n in tf.get_default_graph().as_graph_def().node]

这对我有用:

    import tensorflow as tf

    def get_node_name():
        tf.reset_default_graph()
        with tf.Session() as sess:
            saver = tf.train.import_meta_graph(meta_file)
            graph_def = tf.get_default_graph().as_graph_def()
            name_list = []
    
            
            for node in graph_def.node:
                name_list.append(node.name)
    
            outputs = set(name_list)
    
            for index, output in enumerate(outputs):
                print('Node Name: ', output)

然后运行:

get_node_name()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM