tensorboard使用方法

2019-08-07  本文已影响0人  snowpigppp
import tensorflow as tf
with tf.name_scope(‘命名空间名字’)
    input1 = tf.constant(3.0,name='A')
    # 要显示的名字
    tf.summary.scalar('name', input1)
    # 在tensorboard中显示input1的变化折线图
# 初始化
with tf.Session() as sess:
    writer = tf.summary.FileWriter('logs/', sess.graph)
    # 将训练过程写入logs,以查看tensorboard
    result = sess.run(xxx)
# 训练
for i in range(1000):
    sess.run(train_step,feed_dict={xs:x_data,ys:y_data})
    if(i%50==0): #每50次写一次日志
        result = sess.run(merged,feed_dict={xs:x_data,ys:y_data}) 
#计算需要写入的日志数据
        writer.add_summary(result,i) #将日志数据写入文件

会建立一个events.out.tfevents.前缀的文件
打开终端

tensorboard --logdir=logs文件夹路径

一般路径为
http://localhost:6006

上一篇下一篇

猜你喜欢

热点阅读