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

yipeiwu_com5年前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中的is和==比较两个对象的两种方法

Python中的is和==比较两个对象的两种方法 在Python中有两种方式比较两个对象是否相等,分别是is和==,两者之间是不同的 ==比较的是值(如同java中的equals方...

Python依赖包整体迁移方法详解

Python依赖包整体迁移方法详解

1.新建site-packages目录,进入到site-packages目录下; 2.在site-packages目录下执行pip freeze >requirements.txt...

Python函数可变参数定义及其参数传递方式实例详解

本文实例讲述了Python函数可变参数定义及其参数传递方式。分享给大家供大家参考。具体分析如下: python中 函数不定参数的定义形式如下: 1、func(*args) 传入的参数为以...

python2.7无法使用pip的解决方法(安装easy_install)

1、 在Python IDLE下,我们输入以下代码 from urllib import urlopen【回车】 data = urlopen('http://peak.teleco...

tensorflow中tf.slice和tf.gather切片函数的使用

tf.slice(input_, begin, size, name=None):按照指定的下标范围抽取连续区域的子集 tf.gather(params, indices, valida...