查看tensorflow pb模型文件的节点信息
查看tensorflow pb模型文件的节点信息:
import tensorflow as tf
with tf.Session() as sess:
with open('./quantized_model.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
print graph_def
效果:
# ...
node {
name: "FullyConnected/BiasAdd"
op: "BiasAdd"
input: "FullyConnected/MatMul"
input: "FullyConnected/b/read"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "data_format"
value {
s: "NHWC"
}
}
}
node {
name: "FullyConnected/Softmax"
op: "Softmax"
input: "FullyConnected/BiasAdd"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
}
library {
}
参考:https://tang.su/2017/01/export-TensorFlow-network/
https://github.com/tensorflow/tensorflow/issues/15689
一些核心代码:
import tensorflow as tf
with tf.Session() as sess:
with open('./graph.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
print graph_def
output = tf.import_graph_def(graph_def, return_elements=['out:0'])
print(sess.run(output))
This is part of my Tensorflow frozen graph, I have named the input and output nodes.
>>> g.ParseFromString(open('frozen_graph.pb','rb').read())
>>> g
node {
name: "input"
op: "Placeholder"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
key: "shape"
value {
shape {
dim {
size: -1
}
dim {
size: 68
}
}
}
}
}
...
node {
name: "output"
op: "Softmax"
input: "add"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
}
I ran this model by the following code
(CELL is name of directory where my file is located)
final String MODEL_FILE = "file:///android_asset/" + CELL + "/optimized_graph.pb" ;
final String INPUT_NODE = "input" ;
final String OUTPUT_NODE = "output" ;
final int[] INPUT_SIZE = {1,68} ;
float[] RESULT = new float[8];
inferenceInterface = new TensorFlowInferenceInterface();
inferenceInterface.initializeTensorFlow(getAssets(),MODEL_FILE) ;
inferenceInterface.fillNodeFloat(INPUT_NODE,INPUT_SIZE,input);
and finally
inferenceInterface.readNodeFloat(OUTPUT_NODE,RESULT);
查看tensorflow pb模型文件的节点信息的更多相关文章
- 查看tensorflow Pb模型所有层的名字
代码如下: import tensorflow as tf def get_all_layernames(): """get all layers name"& ...
- tensorflow c++ API加载.pb模型文件并预测图片
tensorflow python创建模型,训练模型,得到.pb模型文件后,用c++ api进行预测 #include <iostream> #include <map> # ...
- h5模型文件转换成pb模型文件
本文主要记录Keras训练得到的.h5模型文件转换成TensorFlow的.pb文件 #*-coding:utf-8-* """ 将keras的.h5的模型文件,转换 ...
- MxNet 模型转Tensorflow pb模型
用mmdnn实现模型转换 参考链接:https://www.twblogs.net/a/5ca4cadbbd9eee5b1a0713af 安装mmdnn pip install mmdnn 准备好mx ...
- 134、TensorFlow检查点checkpoint文件中的信息
# 1.你想创建多少Saver对象就可以创建多少,如果你需要去保存和恢复不同的子图模型 # 同样的变量可以在不同的saver对象中被加载 # 只有在Saver.restore()方法被调用的时候才会对 ...
- tensorflow学习笔记——模型持久化的原理,将CKPT转为pb文件,使用pb模型预测
由题目就可以看出,本节内容分为三部分,第一部分就是如何将训练好的模型持久化,并学习模型持久化的原理,第二部分就是如何将CKPT转化为pb文件,第三部分就是如何使用pb模型进行预测. 一,模型持久化 为 ...
- C#中如何创建xml文件 增、删、改、查 xml节点信息
XML:Extensible Markup Language(可扩展标记语言)的缩写,是用来定义其它语言的一种元语言,其前身是SGML(Standard Generalized Markup Lang ...
- tensorflow的ckpt文件总结
1.TensorFlow的模型文件 --checkpoint_dir | |--checkpoint | |--MyModel.meta | |--MyModel.data-00000-of-0000 ...
- delphi 文件操作(信息获取)
delphi获取Exe文件版本信息的函数 Type TFileVersionInfo = Record FixedInfo:TVSFixedFileInfo; {版本信息} CompanyName:S ...
随机推荐
- 在mac上快捷找到nodejs的安装路径
打开控制台输入 which node ,得到的输出结果就是node安装路径
- [Windows Server 2008] 安装网站伪静态
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:安装IIS伪静 ...
- 在把table表格中的数据导出到Excel的时候,以科学计数法显示位数多的数字时怎么解决?
sbHtml.AppendFormat("<td> {0}</td>", data[i].IDcard.ToString()); sbHtml.Append ...
- php 在Linux下的安装
1.获取php源码 wget http://cn2.php.net/get/php-5.6.6.tar.gz/from/this/mirror mv mirror php-5.6.6.tar.gz t ...
- animation与transition区别
transition: 过渡属性 过渡所需要时间 过渡动画函数 过渡延迟时间:默认值分别为:all 0 ease 0 1.局限性: 1)只能设置一个属性 2)需要伪类/事件触发才执行 3)只能设置动画 ...
- sysbench测试阿里云CPU
参考 https://wiki.mikejung.biz/Benchmarking 买了一个1核的ECS,测试一下CPU性能 第一次是只用1个thread去跑 [root@iZwz9fy718twfi ...
- c/c++排坑(2) -- c语言中的符号重载
所谓的符号重载就是在不同的上下文环境里有不同的意义.甚至有些关键字也被重载而具有好几种意义,这也是C语言的作用域规则对程序员不那么清晰的主要原因. 本章内容摘自<c专家编程>P37. 大家 ...
- 计蒜客 劫富济贫 (Trie树)
链接 : Here! 思路 : Trie树裸题, 由开始给出的名字建一棵字典树, 然后每次查询一下抢♂劫的人名是否在字典树中, 复杂度也不清楚是多少, 反正是没给出 $M$ 的范围, 开始时用 $ha ...
- LIS(两种方法求最长上升子序列)
首先得明白一个概念:子序列不一定是连续的,可以是断开的. 有两种写法: 一.动态规划写法 复杂度:O(n^2) 代码: #include <iostream> #include <q ...
- Unity jointmoto
jointmoto是模拟电机的,他的参数包括了最高车速和最大扭矩 扭矩总是正数,而目标车速决定了方向