[原创] 在树莓派上跑起来TensorBoard

本文软硬件环境:
树莓派:3代 Model B V1.2
OS:Arch Linux ARM,32bit

TensorBoard是Tensorflow的可视化工具。当我们用这篇文章里的方法在树莓派上安装好Tensorflow之后,TensorBoard自然就装好了。于是,下面只剩下怎么启动它的问题。
以下是一个例子。

首先,我们从TensorFlow的官方Github里下载这个文件:

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py

它实现了一个模型训练的过程,并且在模型训练的过程中,将TensorBoard所需的数据文件,输出到了 /tmp/tensorflow/mnist/logs/mnist_with_summaries 这个目录下(写死在 mnist_with_summaries.py 文件中,为了简单无需修改)。
文章来源:http://www.codelast.com/
之后我们把这个模型训练的程序跑起来:

python2 mnist_with_summaries.py

然后程序会自动去下载MNIST数据,并开始训练模型:

Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz
Accuracy at step 0: 0.1114
Accuracy at step 10: 0.6652
Accuracy at step 20: 0.8119
Accuracy at step 30: 0.8533
Accuracy at step 40: 0.868
Accuracy at step 50: 0.8723
Accuracy at step 60: 0.8779
Accuracy at step 70: 0.879
Accuracy at step 80: 0.8817
Accuracy at step 90: 0.8876
Adding run metadata for 99
Accuracy at step 100: 0.896
Accuracy at step 110: 0.9061
Accuracy at step 120: 0.9116
Accuracy at step 130: 0.9167
Accuracy at step 140: 0.9216
Accuracy at step 150: 0.915
Accuracy at step 160: 0.9246
Accuracy at step 170: 0.9267
Accuracy at step 180: 0.9215
Accuracy at step 190: 0.9207
Adding run metadata for 199
Accuracy at step 200: 0.9287
Accuracy at step 210: 0.933
Accuracy at step 220: 0.9307
Accuracy at step 230: 0.9308
......
文章来源:http://www.codelast.com/
在这个漫长的过程中,我们可以去启动TensorBoard了:
tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries
其中,--logdir参数指定的目录就是 mnist_with_summaries.py 程序里用 --log_dir 参数指定的那个路径,TensorBoard会从这个路径下读取数据并可视化展示在web页面中。
过一会就会看到命令行提示:

Starting TensorBoard 41 on port 6006
(You can navigate to http://10.0.0.2:6006)
所以现在打开浏览器,访问这个地址,就可以看到图了:
tensorboard exmaple scalars
文章来源:http://www.codelast.com/
tensorboard example graph

 

文章来源:https://www.codelast.com/
➤➤ 版权声明 ➤➤ 
转载需注明出处:codelast.com 
感谢关注我的微信公众号(微信扫一扫):

wechat qrcode of codelast

发表评论