1 、寫一個簡單實例,完成tensorboard 日誌輸出功能,示例代碼如下:
import tensorflow as tf
input1 = tf.constant([1.0, 2.0, 3.0], name='input1')
input2 = tf.Variable(tf.random_uniform([3]), name='input2')
output = tf.add_n([input1, input2], name='add')
model = tf.initialize_all_variables()
with tf.Session() as sess:
merged = tf.summary.merge_all()
writer = tf.summary.FileWriter('E:/TensorBoard/test', sess.graph )
sess.run(model)
print(sess.run(output))
writer.close()
2、啓動tensorboard
按照教程:tensorboard --logdir=E://TensorBoard//test ,然後在瀏覽器中訪問 127.0.0.1:6006 並不能訪問。原因未知,但很多資料中這樣寫的。
解決方案:
cd [your log dir]
run commond tensorboard --logdir ./ --host=127.0.0.1
然後在瀏覽器中打開:http://127.0.0.1:6006 就可以看到了