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

yipeiwu_com6年前Python基础

TensorFlow 定义输入节点名称input_name:

 with tf.name_scope('input'):
  bottleneck_input = tf.placeholder_with_default(
    bottleneck_tensor,
    shape=[batch_size, bottleneck_tensor_size],
    name='Mul')

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

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查看输入节点和输出节点名称方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python 解析html之BeautifulSoup

复制代码 代码如下:# coding=utf-8 from BeautifulSoup import BeautifulSoup, Tag, NavigableString from S...

python实现图片变亮或者变暗的方法

python实现图片变亮或者变暗的方法

本文实例讲述了python实现图片变亮或者变暗的方法。分享给大家供大家参考。具体实现方法如下: import Image # open an image file (.jpg or....

python+matplotlib演示电偶极子实例代码

python+matplotlib演示电偶极子实例代码

使用matplotlib.tri.CubicTriInterpolator.演示变化率计算: 完整实例: from matplotlib.tri import ( Triang...

初步解析Python下的多进程编程

要让Python程序实现多进程(multiprocessing),我们先了解操作系统的相关知识。 Unix/Linux操作系统提供了一个fork()系统调用,它非常特殊。普通的函数调用,...

python将字符串以utf-8格式保存在txt文件中的方法

python将字符串以utf-8格式保存在txt文件中的方法

如下所示: #ltp_data 字符串 写进777.txt 1、 def save(filename, contents): fh = open(filename, 'w',...