本文介紹將訓練好的model.pb文件在tensorboard中展示其網絡結構。
1. 從pb文件中恢復計算圖
import tensorflow as tf model = 'model.pb' #請將這里的pb文件路徑改為自己的 graph = tf.get_default_graph() graph_def = graph.as_graph_def() graph_def.ParseFromString(tf.gfile.FastGFile(model, 'rb').read()) tf.import_graph_def(graph_def, name='graph') summaryWriter = tf.summary.FileWriter('log/', graph)
執行以上代碼就會生成文件在log/events.out.tfevents.1535079670.DESKTOP-5IRM000。
2. 在tensorboard中加載
tensorboard --logdir D:\TCL\log
3. 在瀏覽器中
拷貝網站鏈接在瀏覽器中即可。