首页 > 技术文章 > 如何使用tensorboard查看tensorflow  graph****.pb文件的模型结构

YouXiangLiThon 2018-12-19 14:38 原文

参考网上的:https://github.com/tensorflow/tensorflow/issues/8854

import tensorflow as tf
from tensorflow.python.platform import gfile
with tf.Session() as sess:
    model_filename ='PATH_TO_PB.pb'
    with gfile.FastGFile(model_filename, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        g_in = tf.import_graph_def(graph_def)
     LOGDIR='YOUR_LOG_LOCATION'
     train_writer = tf.summary.FileWriter(LOGDIR)
     train_writer.add_graph(sess.graph)



推荐阅读