在pycharm中运行程序,如下代码所示
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_d")
e = tf.add(c, d, name="add_e")
sess = tf.Session()
res = sess.run(e)
writer = tf.summary.FileWriter('./my_graph', sess.graph)
writer.close()
print(res)
sess.close()
然后在tensorboard的安装目录下打开cmd 即
C:\Users\dell\AppData\Local\Programs\Python\Python36\Lib\site-packages\tensorboard>python main.py --logdir=E:\JustForNLP\testTensorBoard\my_graph
这时,CMD框里会出现一个网址,将该地址在浏览器中打开即可