1.启动tensorboard
tensorboard --logdir="./logs" --port 6006
2.显示graph
import tensorflow as tf a=tf.constant(2) b=tf.constant(3) x=tf.add(a,b) sess = tf.Session() writer=tf.summary.FileWriter('./logs',sess.graph) writer.close()
3.查看变量
import tensorflow as tf a = tf.constant(1.0,name="a") b = tf.random_normal(shape=[], mean=0, stddev=1, name='b') print a.get_shape() print b.get_shape() x=tf.add(a,b) tf.summary.scalar('x', x) tf.summary.histogram('x_h', x) merged = tf.summary.merge_all() sess = tf.Session() writer=tf.summary.FileWriter('./logs',sess.graph) step = 0 while True: mysum = sess.run(merged) writer.add_summary(mysum,step) step+=1 writer.close()