计算图原理:
计算图原理- jupyterh中计算图源码:
# tf的可视化工具,写日志,两者运行不同的进程里
import tensorflow as tf
# 清除默认图和不断生成的节点
tf.reset_default_graph()
logdir = 'log/'
input1 = tf.constant([1.0, 2.0, 3.0], name = 'input1')
# 产生随机数
input2 = tf.Variable(tf.random_uniform([3]), name = 'input2')
output = tf.add_n([input1, input2], name = 'add')
# 生成一个写日志的writer 并将当前的tf计算图写入日志
writer = tf.summary.FileWriter(logdir, tf.get_default_graph())
writer.close()
print('END!')
当前目中log文件夹中产生日志文件:event***.local:
image.png
- 如使用tensorboard时遇到“ValueError: Duplicate plugins for name projector”的错误
原因:mac环境的终端与jupyter下均安装了tensorboard,重复安装
解决方法:从conda进入terminal->pip uninstall tensorboard
-
之后从anaconda启动terminal窗口,配置tensorboard数据流图的显示地址:
image.png
运行tensorboard --logdir ./log/ --host localhost
显示的文件为log下的日志文件,显示地址默认为localhost:6006,运行如下:
-
浏览器显示数据流图如下:
image.png
若端口被占用则自动更新端口,如6007。
tensorBoard的API为:
tensorboard.png
网友评论