为了方便调试参数以及调整网络结构,我们需要将计算图可视化出来,以便能够更好的进行下一步的决策。Tensorflow提供了一个TensorBoard工具,可以满足上面的需求。
编译环境:pycharm
1.tensorboard安装
本文在anaconda-prompt环境下安装tensorboard,分为两步:
(1)激活tensorflow环境
activate tensorflow
(2)安装tensorboard
pip install tensorboard
2.tensorboard使用
(1)编写一个生成图的py代码
import tensorflow as tf
a = tf.constant(5, name="input_a")
b = tf.constant(3, name="input_b")
c = tf.multiply(a, b, name="mul_c")
d = tf.add(a, b, name="add_c")
e = tf.add(c, d, name="add_e")
sess = tf.Session()
output = sess.run(e)
writer = tf.summary.FileWriter('./my_graph', sess.graph)
writer.close()
sess.close()
(2)编译执行