2018年3月1日 星期四

最簡單的方法玩玩 tensorboard (不需動腦)

How to use tensorboard
井民全, Jing, mqjing@gmail.com


Google doc: This Document
Back to the Main Page
先別談細節, 先讓 tensorboard 跑起來玩一下. 會動了, 你就可以閱讀接下來的 [Further Reading] 文章.
Fig. A tensorboard running example.


TL;DR

這份文件讓你在最短時間, 不需要動大腦的就可以玩 tensorboard.
用圖形化的方式觀察你的 tensorflow 模型的訓練收斂情況.


Before you do anything

  1. [installation, tensorflow] How to install TensorFlow using Anaconda (view)

Show Me the Example

Step 1: Download the Minist Source with Summary Code


Step 2: Run the Training and Testing Process
Command
python minist_with_summaries.py
E.g.


Step 3: Run the Tensorboard
Command
tensorboard --logdir=/tmp/tensorflow/mnist


Got Error

Traceback (most recent call last):
 File "/home/jing/anaconda3/envs/tensorflow/bin/tensorboard", line 4, in
   import tensorflow.tensorboard.tensorboard
ImportError: No module named 'tensorflow.tensorboard'

Workaround

Modify the tensorboard script
~/anaconda3/envs/tensorflow/bin/tensorboard
#!/home/jing/anaconda3/envs/tensorflow/bin/python
if __name__ == '__main__':
   import sys
   #import tensorflow.tensorboard.tensorboard
   import tensorboard.main

   #sys.exit(tensorflow.tensorboard.tensorboard.main())
   sys.exit(tensorboard.main.main())

Reference


Run tensorboard
tensorboard --logdir=/tmp/tensorflow/mnist


Verification

Open  http://jing-VirtualBox:6006


E.g.


References

  1. Original Source (ref)
  2. Source with Summary (ref)


Further Reading

  1. [ts, digital] MNIST for ML Beginners -- Digital number recognition (view)
  2. [cnn, digital] A Guide to TF Layers: Building a Convolutional Neural Network (view)
  3. [tensorboard, tuto] TensorBoard: Visualizing Learning (ref)