直接介绍转换过程和查看方法
1.转换过程
import tensorflow as tf
import os
def wirte_graph_log(meta_file,log_dir):
if not os.path.exists(log_dir):
os.mkdir(log_dir)
g = tf.Graph()
with g.as_default() as g:
tf.train.import_meta_graph(meta_file)
with tf.Session(graph=g) as sess:
tf.summary.FileWriter(logdir=log_dir,graph=g)
if __name__ == '__main__':
wirte_graph_log('./model.ckpt.meta','./log/')
2.使用tensorboard查看
tensorboard --logdir=log
运行时如果这个错误:AttributeError: module 'tensorboard.util' has no attribute 'Retrier'
解决方法:
pip uninstall tb-nightly
pip uninstall tensorboard
pip uninstall tensorflow-gpu
pip install tensorflow-gpu==1.8 -i https://pypi.tuna.tsinghua.edu.cn/simple
即卸载掉这个包:tb-nightly,为了安全起见,我把tensorboard和tensorflow-gpu卸载重新安装了,安装tensorflow-gpu的时候会自动安装tensorboard,我这里安装时1.8版本。
参考:
https://www.lizenghai.com/archives/29105.html
https://github.com/tensorflow/tensorboard/issues/1724