【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 ...
随机推荐
- 2019牛客暑期多校训练营(第八场)A:All-one Matrices(广告牌问题 单调队列)
题意:给出N*M的01矩阵,求矩阵个数,满足矩阵内全是‘1’,,而且被至少一个’0‘围住.(假设边界外是‘0’.(N,M<3000) 思路:这类问题,一般解决就是两个方向: A:压缩一维,即枚举 ...
- arrayAppend.php
<?php $t_full_projects = array(); $t_full_projects[] ='a'; $t_full_projects[] ='b'; $t_full_proje ...
- js回调与异步加载的用法
以前还是菜鸟的时候(虽然现在依然很菜 -_-|| )对异步加载与回调函数的技术无比向往,但也一直没有使用过,这次因为页面逻辑太过复杂,一堆请求逻辑,如果还是用顺序请求,页面的速度... 领导又要挠头了 ...
- Redis : REmote DIctionary Server
REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统. Redis是一个开源的使用ANSI C语言编写.遵守B ...
- Spring核心模块解析
Spring框架是一个轻量级的集成式开发框架,可以和任何一种框架集成在一起使用,可以说是一个大的全家桶.Spring从1.x发展到现在的5.x可以说是越来越强大,下面来看看Spring都包含哪些核心的 ...
- Java逆变(Covariant)和协变(Contravariant)
1. 定义 逆变和协变描述的经过类型变换后的类型之间的关系.假如A和B表示类型,f表示类型变换,A ≤B表示A是B的子类型,那么 如果A ≤B,f(A) ≤f(B),那么f是协变 如果A ≤B,f(B ...
- MySQL+keeplived高可用配置
MySQL高可用基础环境:基于MySQL互为主从(双主.主主),请现配置 主备两台机器 主的操作1.在keepalived主服务器上安装keepalived yum -y install keepal ...
- Pandas模块 --- 字符与日期型数据的处理
1,pd.to_datetime( 要转换的日期, format= ), 2,pd.to_datetime.today( ).year ,pd.to_datetime.now( ).year 3,字 ...
- ES6 - 开篇
一些关于es6简单的介绍与了解.初始认知有限,循序完善. ES6: 又叫ES2015,是2015年推出的JavaScript新版本. 相应的,后边推出的ES7.8.9.10等都依次是上一版本发出后一年 ...
- lintcode-1038. 珠宝和石头
题目描述 给定字符串J代表是珠宝的石头类型,而S代表你拥有的石头.S中的每个字符都是你拥有的一个石头. 你想知道你的石头有多少是珠宝. J中的字母一定不同,J和S中的字符都是字母. 字母区分大小写,因 ...