环境
Python 3.5.2
tensorflow : 1.11.0
ubuntu : 16.04
- 先确认安装tensorboard
运行v@v:~$ pip3 show tensorflow
可以看到tensorboard 模块
tensorboard = tensorboard.main:run_main
v@v:~$ pip3 show tensorflow
---
Metadata-Version: 2.0
Name: tensorflow
Version: 1.11.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
Installer: pip
License: Apache 2.0
Location: /home/v/.local/lib/python3.5/site-packages
Requires: astor, numpy, six, grpcio, wheel, termcolor, setuptools, protobuf, keras-preprocessing, absl-py, keras-applications, tensorboard, gast
Classifiers:
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Mathematics
Topic :: Scientific/Engineering :: Artificial Intelligence
Topic :: Software Development
Topic :: Software Development :: Libraries
Topic :: Software Development :: Libraries :: Python Modules
Entry-points:
[console_scripts]
freeze_graph = tensorflow.python.tools.freeze_graph:run_main
saved_model_cli = tensorflow.python.tools.saved_model_cli:main
tensorboard = tensorboard.main:run_main
tflite_convert = tensorflow.contrib.lite.python.tflite_convert:main
toco = tensorflow.contrib.lite.python.tflite_convert:main
toco_from_protos = tensorflow.contrib.lite.toco.python.toco_from_protos:main
You are using pip version 8.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
v@v:~$
- 测试代码 1_simple.py
import tensorflow as tf
# 定义一个计算图,实现两个向量的减法操作
# 定义两个输入,a为常量,b为变量
a=tf.constant([10.0, 20.0, 40.0], name='a')
b=tf.Variable(tf.random_uniform([3]), name='b')
output=tf.add_n([a,b], name='add')
# 生成一个具有写权限的日志文件操作对象,将当前命名空间的计算图写进日志中
writer=tf.summary.FileWriter('/tmp/logs', tf.get_default_graph())
writer.close()
运行测试代码,日志写入到/tmp/logs
mkdir /tmp/logs
python3 1_simple.py
运行tensorboard
python3 -m tensorboard.main --logdir=/tmp/logs
输出
v@v:~/tutorials/python_tutorial/tensorboard$ python3 -m tensorboard.main --logdir=~/logs
TensorBoard 1.11.0 at http://v:6006 (Press CTRL+C to quit)
- 浏览器访问
http://v:6006
,这个地址是第四步输出的