【tensorflow-v2.0】如何查看模型的输入输出流的属性
操作过程:
1. 查看mobilenet的variables
loaded = tf.saved_model.load('mobilenet')
print('MobileNet has {} trainable variables: {},...'.format(
len(loaded.trainable_variables),
', '.join([v.name for v in loaded.trainable_variables[:5]])))
trainable_variable_ids = {id(v) for v in loaded.trainable_variables}
non_trainable_variables = [v for v in loaded.variables if id(v) not in trainable_variable_ids]
print('MobileNet also has {} non-trainable variables: {}, ...'.format(
len(non_trainable_variables),
', '.join([v.name for v in non_trainable_variables[:3]])))
输出:输出trainable_variables的后5个variables,non_trainable_variables的后3个variables.
MobileNet has trainable variables: conv1/kernel:, conv1_bn/gamma:, conv1_bn/beta:, conv_dw_1/depthwise_kernel:, conv_dw_1_bn/gamma:,...
MobileNet also has non-trainable variables: conv1_bn/moving_mean:, conv1_bn/moving_variance:, conv_dw_1_bn/moving_mean:, ...
但是这种方法输出model/detector模型的variables却出错;
Traceback (most recent call last):
File "inspect_saved_model.py", line , in <module>
len(facebox_model.trainable_variables),
AttributeError: '_UserObject' object has no attribute 'trainable_variables'
原因还没找出来,有知道的可以私信博主哈~
2. 使用命令行查看模型的signatures
usage: saved_model_cli show [-h] --dir DIR [--all]
[--tag_set TAG_SET] [--signature_def SIGNATURE_DEF_KEY]
例如
saved_model_cli show --dir mobilenet/ --all
or
saved_model_cli show --dir model/detector/ --tag_set serve --signature_def serving_default
输出
(tf_test) ~/workspace/test_code/github_test/faceboxes-tensorflow$ saved_model_cli show --dir model/detector --all MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs: signature_def['__saved_model_init_op']:
The given SavedModel SignatureDef contains the following input(s):
The given SavedModel SignatureDef contains the following output(s):
outputs['__saved_model_init_op'] tensor_info:
dtype: DT_INVALID
shape: unknown_rank
name: NoOp
Method name is: signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['images'] tensor_info:
dtype: DT_FLOAT
shape: (-, -, -, -)
name: serving_default_images:
The given SavedModel SignatureDef contains the following output(s):
outputs['boxes'] tensor_info:
dtype: DT_FLOAT
shape: (-, , )
name: StatefulPartitionedCall:
outputs['num_boxes'] tensor_info:
dtype: DT_INT32
shape: (-)
name: StatefulPartitionedCall:
outputs['scores'] tensor_info:
dtype: DT_FLOAT
shape: (-, )
name: StatefulPartitionedCall:
Method name is: tensorflow/serving/predict
这个是model/detector模型的输出;
参考
1. tensorflow1.x;
2. tf_saved_model;
完
【tensorflow-v2.0】如何查看模型的输入输出流的属性的更多相关文章
- 使用TensorFlow v2.0构建卷积神经网络
使用TensorFlow v2.0构建卷积神经网络. 这个例子使用低级方法来更好地理解构建卷积神经网络和训练过程背后的所有机制. CNN 概述 MNIST 数据集概述 此示例使用手写数字的MNIST数 ...
- TensorFlow v2.0实现Word2Vec算法
使用TensorFlow v2.0实现Word2Vec算法计算单词的向量表示,这个例子是使用一小部分维基百科文章来训练的. 更多信息请查看论文: Mikolov, Tomas et al. " ...
- 使用TensorFlow v2.0构建多层感知器
使用TensorFlow v2.0构建一个两层隐藏层完全连接的神经网络(多层感知器). 这个例子使用低级方法来更好地理解构建神经网络和训练过程背后的所有机制. 神经网络概述 MNIST 数据集概述 此 ...
- TensorFlow v2.0实现逻辑斯谛回归
使用TensorFlow v2.0实现逻辑斯谛回归 此示例使用简单方法来更好地理解训练过程背后的所有机制 MNIST数据集概览 此示例使用MNIST手写数字.该数据集包含60,000个用于训练的样本和 ...
- TensorFlow v2.0的基本张量操作
使用TensorFlow v2.0的基本张量操作 from __future__ import print_function import tensorflow as tf # 定义张量常量 a = ...
- tensorflow 1.0 学习:模型的保存与恢复(Saver)
将训练好的模型参数保存起来,以便以后进行验证或测试,这是我们经常要做的事情.tf里面提供模型保存的是tf.train.Saver()模块. 模型保存,先要创建一个Saver对象:如 saver=tf. ...
- tensorflow 1.0 学习:模型的保存与恢复
将训练好的模型参数保存起来,以便以后进行验证或测试,这是我们经常要做的事情.tf里面提供模型保存的是tf.train.Saver()模块. 模型保存,先要创建一个Saver对象:如 saver=tf. ...
- TensorFlow 2.0高效开发指南
Effective TensorFlow 2.0 为使TensorFLow用户更高效,TensorFlow 2.0中进行了多出更改.TensorFlow 2.0删除了篇冗余API,使API更加一致(统 ...
- 在Anaconda3环境下安装并切换 Tensorflow 2.0 环境
背景 Anaconda切换各种环境非常方便,现在我们就来介绍一下如何使用anaconda安装tensorflow环境. anaconda v3.5 from 清华镜像站 tensorflow v2.0 ...
随机推荐
- ArcGIS 生成等值线图
1.打开ArcCatalog,准备工作(1)菜单:Customize -> Extensions...,在打开的对话框中把里面的东西都勾上.实际要用的应该是GeoStatistical Anal ...
- 20180523模拟赛T2——前缀!
简化版题面 jyt毒瘤,写了超长的题面,要看完整题面的翻到最后-- 定义\(f_0(x) = A_x\),\(f_n(x) = \sum^x_{i = 1} f_{n-1}(i)\).给出长度为\(N ...
- 每隔15s异步刷新手机页面
前台异步js发请求代码: <script type="text/javascript"> var lightArr; var lightHistoryArr; /* 每 ...
- python--requests模块初识
requests,发送http请求(用python模拟浏览器浏览网页)requests.get("http://www.baidu.com") 示例: import request ...
- Laravel 自定义公共函数全局使用,并设置自定加载
开发中经常定义一些公共函数(如:获取用户信息.csv导入导出等常用函数),方便控制层,模型层调用. 那么在Laravle框架中怎么使用? 方法如下: 1.在根目录app下新建公共目录Library/U ...
- elasticsearch集群搭建-windows
1.下载elasticsearch到本地并解压 下载地址: https://www.elastic.co/cn/downloads/elasticsearch 解压之后复制两份,node1当作主节点, ...
- php面试题收藏
总结几个要素: 1.个人简介名字大写,内容需要详实,一是可以给人留下映像,二是减少不必要的与面试官交换个人信息的时间.准备一份好的口头自我介绍是很有必要的,毕竟准备一次能用很久,时间花在上面很实用,面 ...
- 洛谷 P2577 [ZJOI2005]午餐 题解
每日一题 day56 打卡 Analysis 算法:贪心+dp 容易想到贪心:吃饭慢的先打饭节约时间, 所以先将人按吃饭时间从大到小排序. 然后就是dp了: 首先,应该想到f[i][j][k]:前i个 ...
- MongoDB Map Reduce(转载)
MongoDB Map Reduce Map-Reduce是一种计算模型,简单的说就是将大批量的工作(数据)分解(MAP)执行,然后再将结果合并成最终结果(REDUCE). MongoDB提供的Map ...
- Vue的数据双向绑定原理——Object-defineProperty
一.定义 ①方法会直接在一个对象上定义一个新属性,或者修改一个已经存在的属性, 并返回这个对象. ②vue.js的双向数据绑定就是通过Object.defineProperty方法实现的,俗称属性拦截 ...