代碼如下:
import tensorflow as tf
from tensorflow.python.platform import gfile
model = 'pb_path'
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)
使用步驟:
1.修改display_model_nodes.py裏的model定義爲自己的pb模型
2.python display_model_nodes.py會在log裏生成out日誌
3.tensorboard --logdir=log
且會在下方出現網頁地址 TensorBoard 1.10.0 at http://oeasy:6006 (Press CTRL+C to quit)
4.在瀏覽器中打輸入:http://oeasy:6006就能看到模型的各個節點了
結果如下: