Tensorflow pb模型可视化

  1. 新建 log 文件夹
  2. 执行以下代码

    import tensorflow as tf
    from tensorflow.python.platform import gfile
    model = 'model.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)
    
  3. 在log文件夹上一层执行 tensorboard –logdir log,浏览器访问即可