笔记类
程序员文章站
2023-12-22 22:10:04
...
查看keras模型的输入输出节点名称
有两种方式
1.直接调用model.inputs和model.outputs
2.利用.pb文件查看,代码如下
import tensorflow as tf
import os
model_dir = './'
model_name = 'frozen_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')```