1.可视化神经网络图:
with tf.name_scope("input"): with tf.name_scope("image"): X = tf.placeholder(tf.float32, [None, IMAGE_HEIGHT*IMAGE_WIDTH]) with tf.name_scope("label"): Y = tf.placeholder(tf.float32, [None, MAX_CAPTCHA*CHAR_SET_LEN]) with tf.name_scope("dropout"): keep_prob = tf.placeholder(tf.float32) # dropout
with tf.name_scope("input"): 进行命名空间限制
2.可视化loss,accuracy曲线:
tf.summary.scalar("loss",loss)
tf.summary.scalar("accyracy",accuracy)
def variable_summaries(var): with tf.name_scope('summaries'): mean = tf.reduce_mean(var) tf.summary.scalar('mean', mean) with tf.name_scope('stddev'): stddev = tf.sqrt(tf.reduce_mean(tf.square(var-mean))) tf.summary.scalar('stddev', stddev) tf.summary.scalar('max', tf.reduce_max(var)) tf.summary.scalar('min', tf.reduce_min(var)) tf.summary.histogram('histogram', var)
3.汇总所有绘制信息,图、曲线等等
tf.summary.merge_all(key='summaries')
4.将汇总的protobuf 写入到event文件中
writer = tf.summary.FileWriter(r"C:\Users\Administrator\log")
[_, s] = sess.run([optimizer, summ], feed_dict={X: batch_x, Y: batch_y, keep_prob: 0.75})
writer.add_summary(s, step)
对于网络图的保存 必须把graph单独声明要不然不会保存图
writer = tf.summary.FileWriter(r"F:\env\log2",sess.graph)
5.在cmd运行中执行(写入event的上一层列入上面在Administrator下执行):
tensorboard --logdir=./log
扫描二维码关注公众号,回复:
1564385 查看本文章
参考地址:https://blog.csdn.net/smf0504/article/details/56369758