多层感知机的Tensorboard可视化
1 | from __future__ import print_function |
导入数据集
1 | # Import MNIST data |
Extracting ./data/train-images-idx3-ubyte.gz
Extracting ./data/train-labels-idx1-ubyte.gz
Extracting ./data/t10k-images-idx3-ubyte.gz
Extracting ./data/t10k-labels-idx1-ubyte.gz
设置参数
1 | # Parameters |
创建多层感知机函数
1 | # Create model |
创建模型和操作(模型+损失函数+优化+准确率)
1 | # Encapsulating all ops into scopes, making Tensorboard's Graph |
初始化并合并操作
1 | # Initialize the variables (i.e. assign their default value) |
INFO:tensorflow:Summary name W1:0 is illegal; using W1_0 instead.
INFO:tensorflow:Summary name W2:0 is illegal; using W2_0 instead.
INFO:tensorflow:Summary name W3:0 is illegal; using W3_0 instead.
INFO:tensorflow:Summary name b1:0 is illegal; using b1_0 instead.
INFO:tensorflow:Summary name b2:0 is illegal; using b2_0 instead.
INFO:tensorflow:Summary name b3:0 is illegal; using b3_0 instead.
INFO:tensorflow:Summary name W1:0/gradient is illegal; using W1_0/gradient instead.
INFO:tensorflow:Summary name W2:0/gradient is illegal; using W2_0/gradient instead.
INFO:tensorflow:Summary name W3:0/gradient is illegal; using W3_0/gradient instead.
INFO:tensorflow:Summary name b1:0/gradient is illegal; using b1_0/gradient instead.
INFO:tensorflow:Summary name b2:0/gradient is illegal; using b2_0/gradient instead.
INFO:tensorflow:Summary name b3:0/gradient is illegal; using b3_0/gradient instead.
训练并保存log
1 | # Start training |
Epoch: 0001 cost= 82.491150440
Epoch: 0002 cost= 11.219711702
Epoch: 0003 cost= 6.885841494
Epoch: 0004 cost= 4.898687713
Epoch: 0005 cost= 3.742709111
Epoch: 0006 cost= 2.969850923
Epoch: 0007 cost= 2.429568350
Epoch: 0008 cost= 2.024799560
Epoch: 0009 cost= 1.742192560
Epoch: 0010 cost= 1.494883727
Epoch: 0011 cost= 1.313867836
Epoch: 0012 cost= 1.153405372
Epoch: 0013 cost= 1.022956383
Epoch: 0014 cost= 0.917282970
Epoch: 0015 cost= 0.831443023
Epoch: 0016 cost= 0.739466778
Epoch: 0017 cost= 0.660427638
Epoch: 0018 cost= 0.606233582
Epoch: 0019 cost= 0.547995506
Epoch: 0020 cost= 0.506534999
Epoch: 0021 cost= 0.462353780
Epoch: 0022 cost= 0.424939641
Epoch: 0023 cost= 0.399291764
Epoch: 0024 cost= 0.364750651
Epoch: 0025 cost= 0.334185596
Optimization Finished!
Accuracy: 0.9215
Run the command line:
--> tensorboard --logdir=./log
Then open http://0.0.0.0:6006/ into your web browser
损失和准确率折线图
计算图模型的可视化
权重及其梯度直方图
偏置及其梯度直方图
FeatureMap 直方图
参考
[TensorBoard: 图表可视化]http://wiki.jikexueyuan.com/project/tensorflow-zh/how_tos/graph_viz.html