tensorflow从pb文件导出模型图

这篇博客介绍了如何使用Python脚本将TensorFlow模型的.pb文件转换为模型图,并将其保存到log目录。通过运行指定的脚本,然后启动TensorBoard,可以在浏览器中查看模型图。注意,可能会遇到多个图事件警告,但最新的事件会覆盖之前的图。通过输入TensorBoard提供的URL,可以在1.11.0版本的TensorBoard中查看模型。
摘要由CSDN通过智能技术生成

运行下面的程序,将graph信心保存在log目录:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import tensorflow as tf
from tensorflow.python.platform import gfile
model = 'model.pb' #请将这里的pb文件路径改为自己的
graph = tf.get_default_graph()
graph_def = graph.as_graph_def()
graph_def.ParseFromString(gfile.FastGFile(model, 'rb').read())
tf.import_graph_def(graph_def, name='graph')
summaryWriter = tf.summary.FileWriter('log/', graph)

运行:tensorboard --logdir log  

W0413 10:41:21.149763 Reloader tf_logging.py:120] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph events.  Overwriting the graph with the newest event.
W0413 10:41:21.149763 140061330405120 tf_logging.py:120] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph event

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值