【tensorflow】顯示pb文件的graph

import tensorflow as tf
from tensorflow.python.platform import gfile

pb_file = ‘xxx/xxx/xxx.pb’
pb_log_dir = ‘xxx/xxx/log/def show_pb_graph():

    graph = tf.get_default_graph()
    graph_def = graph.as_graph_def()
    graph_def.ParseFromString(gfile.FastGFile(pb_file, 'rb').read())
    tf.import_graph_def(graph_def, name='graph')

    writer = tf.summary.FileWriter(pb_log_dir, graph)
    writer.close()

    print('\n logs has been saved at  {} \n'.format(pb_log_dir))



if __name__ == '__main__':
    show_pb_graph()

Note

  • .ckpt -> .pb ,一般模型縮小70%左右。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章