例子
1 | import tensorflow as tf |
1 | #载入数据集 |
Extracting MNIST_data\train-images-idx3-ubyte.gz
Extracting MNIST_data\train-labels-idx1-ubyte.gz
Extracting MNIST_data\t10k-images-idx3-ubyte.gz
Extracting MNIST_data\t10k-labels-idx1-ubyte.gz
epoch:0, accuracy:0.909
epoch:1, accuracy:0.9272
epoch:2, accuracy:0.9358
epoch:3, accuracy:0.942
epoch:4, accuracy:0.9459
总结
Tensorboard使用方法:
STEP 1:在sess外部给tensor加上命名空间name_scope 和 name。
name_scope对应矩形
name对应矩形内部的tensor1
2
3with tf.name_scope("input"):
input_x = tf.placeholder(tf.float32, [None, 784], name="input_x")
input_y = tf.placeholder(tf.float32, [None, 10], name="input_y")
STEP 2:在sess内部加上打印日志1
writer = tf.summary.FileWriter("logs", sess.graph)
STEP 3:运行代码。
如果之前运行过,可以restart kernel选择“Restart & Run All”
STEP 4:将tensorboard目录D:\Anaconda3\envs\tensorflow\Scripts
添加的环境变量中,打开anaconda cmd,切换到log的相应盘符下,否则tensorboard无法显示。接下来输入命令1
tensorboard --logdir=D:/Tensorflow/logs
复制生成的地址在浏览器打开