【发布时间】:2021-01-29 05:36:23
【问题描述】:
到目前为止,我可以获取给定任何 .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]
【问题讨论】:
-
一般来说,使用命名空间来使您的搜索更容易是很有用的。此外,您可以使用
tf.identity为操作的输出指定您喜欢的名称。您可以使用graph_def.get_tensor_by_name('mynamespace/myvar:0')获取变量名称。我还没有找到更好的方法。 -
您找到解决方案了吗?
标签: python tensorflow machine-learning deep-learning