Bootstrap

TensorBoard可视化学习

参考window下启动tensorboard

import tensorflow as tf  
with tf.name_scope('input1'):  
    input1 = tf.constant([1.0,2.0,3.0],name="input1")  
with tf.name_scope('input2'):  
    input2 = tf.Variable(tf.random_uniform([3]),name="input2")  
output = tf.add_n([input1,input2],name="add")  
writer = tf.summary.FileWriter("D://log",tf.get_default_graph())  
writer.close()

运行后会在D盘下新建log文件夹。打开cmd,输入“tensorboard --logdir=D://log”,得到网址,在浏览器中输入该网址,进入TensorBoard界面。


遇到的问题:1)代码为

writer = tf.summary.FileWriter("D://log",tf.get_default_graph()

时可显示图,但原来为

writer = tf.summary.FileWriter("/path/to/log",tf.get_default_graph())
则不可显示,据说是路径问题,在启动TensorBoard时logdir不能明确定位到该路径。
2)输入网址“http://10.202.16.130:6006”时无法打开网页,但输入“http://localhost:6006”时则可以查看。结果如下图所示。



简易版,参考tensorboard

import tensorflow as tf
a=tf.constant(2)
b=tf.constant(3)
x=tf.add(a,b)
with tf.Session() as sess:
    writer=tf.summary.FileWriter('./graphs',sess.graph)
    print(sess.run(x))
writer.close()

命令行下输入

python [yourprogram].py
然后输入

tensorboard --logdir="./graphs" --port 6006
打开网页输入地址:http://localhost:6006/

在graph下,如下图所示



调参

;