操作过程:

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】如何查看模型的输入输出流的属性的更多相关文章

  1. 使用TensorFlow v2.0构建卷积神经网络

    使用TensorFlow v2.0构建卷积神经网络. 这个例子使用低级方法来更好地理解构建卷积神经网络和训练过程背后的所有机制. CNN 概述 MNIST 数据集概述 此示例使用手写数字的MNIST数 ...

  2. TensorFlow v2.0实现Word2Vec算法

    使用TensorFlow v2.0实现Word2Vec算法计算单词的向量表示,这个例子是使用一小部分维基百科文章来训练的. 更多信息请查看论文: Mikolov, Tomas et al. " ...

  3. 使用TensorFlow v2.0构建多层感知器

    使用TensorFlow v2.0构建一个两层隐藏层完全连接的神经网络(多层感知器). 这个例子使用低级方法来更好地理解构建神经网络和训练过程背后的所有机制. 神经网络概述 MNIST 数据集概述 此 ...

  4. TensorFlow v2.0实现逻辑斯谛回归

    使用TensorFlow v2.0实现逻辑斯谛回归 此示例使用简单方法来更好地理解训练过程背后的所有机制 MNIST数据集概览 此示例使用MNIST手写数字.该数据集包含60,000个用于训练的样本和 ...

  5. TensorFlow v2.0的基本张量操作

    使用TensorFlow v2.0的基本张量操作 from __future__ import print_function import tensorflow as tf # 定义张量常量 a = ...

  6. tensorflow 1.0 学习:模型的保存与恢复(Saver)

    将训练好的模型参数保存起来,以便以后进行验证或测试,这是我们经常要做的事情.tf里面提供模型保存的是tf.train.Saver()模块. 模型保存,先要创建一个Saver对象:如 saver=tf. ...

  7. tensorflow 1.0 学习:模型的保存与恢复

    将训练好的模型参数保存起来,以便以后进行验证或测试,这是我们经常要做的事情.tf里面提供模型保存的是tf.train.Saver()模块. 模型保存,先要创建一个Saver对象:如 saver=tf. ...

  8. TensorFlow 2.0高效开发指南

    Effective TensorFlow 2.0 为使TensorFLow用户更高效,TensorFlow 2.0中进行了多出更改.TensorFlow 2.0删除了篇冗余API,使API更加一致(统 ...

  9. 在Anaconda3环境下安装并切换 Tensorflow 2.0 环境

    背景 Anaconda切换各种环境非常方便,现在我们就来介绍一下如何使用anaconda安装tensorflow环境. anaconda v3.5 from 清华镜像站 tensorflow v2.0 ...

随机推荐

  1. Template Function

    // TemplateFunction.cpp : Defines the entry point for the console application. // #include "std ...

  2. NameNode和SecondaryNameNode

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/weixin_37838429/artic ...

  3. LeetCode 722. Remove Comments

    原题链接在这里:https://leetcode.com/problems/remove-comments/ 题目: Given a C++ program, remove comments from ...

  4. 入门平衡树: Treap

    入门平衡树:\(treap\) 前言: 如有任何错误和其他问题,请联系我 微信/QQ同号:615863087 前置知识: 二叉树基础知识,即简单的图论知识. 初识\(BST\): \(BST\)是\( ...

  5. 2.Servlet入门

    一.Servlet简介 Servlet为sun公司开发动态web的一门技术 Sun公司在这些API中提供了一个接口叫做:Servlet,如果想开发Servlet程序,需要完成两个小步骤: 编写一个类, ...

  6. Linux 检测 tls

    检测 tls # openssl s_client -connect intl.jdair.net: -tls1

  7. Anniversary party(hdu1520)(poj2342)题解

    原题地址:http://poj.org/problem?id=2342 题目大意: 上司和下属不能同时参加派对,求参加派对的最大活跃值. 关系满足一棵树,每个人都有自己的活跃值(-128~127) 求 ...

  8. UE4的联网系统研究

    1. 物体复制 具体细节可参考官网内容:http://api.unrealengine.com/CHN/Gameplay/Networking/index.html 这里只挑部分点来展开. 首先,分为 ...

  9. 基于centos搭建微信小程序服务,配置及数据库等

    基于centos搭建小程序, ps:请提前20天准备将域名备案,申请ssl证书 实验上机地址:https://cloud.tencent.com/developer/labs/lab/10004 准备 ...

  10. 第09组 Alpha冲刺(1/6)

    队名:观光队 组长博客 作业博客 组员实践情况 王耀鑫 过去两天完成了哪些任务 文字/口头描述 完成服务器连接数据库部分代码 展示GitHub当日代码/文档签入记录 接下来的计划 与服务器连接,配合前 ...