Launching Tensorboard - NameError: name 'tensorboard' is not defined

Launching Tensorboard - NameError: name 'tensorboard' is not defined

我正在尝试启动 tensorboard 并查看我创建的图表。

import tensorflow as tf

logPath = "C:\path\to\log" -- can also be /path/to/log

sess = tf.Session()
file_writer = tf.summary.FileWriter(logPath, sess.graph)

此代码 运行 很好,并在适当的文件夹中创建了一个事件文件,但是当我 运行 在 shell 中使用此命令时:

tensorboard --logdir /path/to/log

我收到以下错误:

Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
tensorboard --logdir /path/to/log
NameError: name 'tensorboard' is not defined

我是否缺少设置?我已经看到了这个错误的另一个问题,但那个解决方案没有解决这个问题。

我已经能够分配节点并纯粹在命令行中工作了好吧,我只想开始测试可视化。

非常感谢。

从错误消息来看,您似乎在 Python shell 处输入了命令 tensorboard。但是,tensorboard 实际上是 Windows 可执行程序的名称,而不是 Python 命令。 因此,您可以通过在“C:\>”Windows 命令提示符下输入相同的命令来代替 运行 TensorBoard。

您是否尝试过添加到脚本的顶部:

from keras.callbacks import TensorBoard