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中executemany和序列的使用方法

详解python中executemany和序列的使用方法 一 代码 import sqlite3 persons=[ ("Jim","Green"), ("Hu","...

在RedHat系Linux上部署Python的Celery框架的教程

在RedHat系Linux上部署Python的Celery框架的教程

 Celery (芹菜)是基于Python开发的分布式任务队列。它支持使用任务队列的方式在分布的机器/进程/线程上执行任务调度。 架构设计  Celery的架构由...

Python中用memcached来减少数据库查询次数的教程

本来我一直不知道怎么来更好地优化网页的性能,然后最近做python和php同类网页渲染速度比较时,意外地发现一个很简单很白痴但是 我一直没发现的好方法(不得不BS我自己):直接像某些ph...

python求质数的3种方法

本文为大家分享了多种方法求质数python实现代码,供大家参考,具体内容如下 题目要求是求所有小于n的质数的个数。 求质数方法1: 穷举法: 根据定义循环判断该数除以比他小的...

Python实现将doc转化pdf格式文档的方法

本文实例讲述了Python实现将doc转化pdf格式文档的方法。分享给大家供大家参考,具体如下: #-*- coding:utf-8 -*- # doc2pdf.py: python...