TensorFlow查看输入节点和输出节点名称方式

时间:2021-11-06 19:20:25

TensorFlow 定义输入节点名称input_name:

?
1
2
3
4
5
with tf.name_scope('input'):
 bottleneck_input = tf.placeholder_with_default(
   bottleneck_tensor,
   shape=[batch_size, bottleneck_tensor_size],
   name='Mul')

TensorFlow查看pb数据库里面的输入节点和输出节点:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import tensorflow as tf
import os
 
model_dir = './tmp/'
model_name = 'output_graph.pb'
 
def create_graph():
  with tf.gfile.FastGFile(os.path.join(
      model_dir, model_name), 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    tf.import_graph_def(graph_def, name='')
 
create_graph()
tensor_name_list = [tensor.name for tensor in tf.get_default_graph().as_graph_def().node]
for tensor_name in tensor_name_list:
  print(tensor_name,'\n')

以上这篇TensorFlow查看输入节点和输出节点名称方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/miao0967020148/article/details/89434253