运行下面的程序,将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 events. Overwriting the graph with the newest event.
TensorBoard 1.11.0 a
使用TensorFlow从.pb文件导出模型图

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

被折叠的 条评论
为什么被折叠?



