为什么此代码不生成张量板可读的日志?

Why does this code not produce a log that is readable by tensorboard?

在 WIndows 10 上使用 Python (3.6) / Jupyter (5.7.8) .. 我尝试了很多尝试为张量板生成日志文件的简单示例,包括:

logs_base_dir = "C:/tensorlogs"
%load_ext tensorboard.notebook
# %tensorboard --port=6006 --logdir {logs_base_dir}

os.makedirs(logs_base_dir, exist_ok=True)
%tensorboard --port=6008 --logdir {logs_base_dir}

a = tf.constant([10])
b = tf.constant([20])
c = tf.add(a,b)

with tf.Session() as sess:
    # or creating the writer inside the session
    writer = tf.summary.FileWriter(logs_base_dir, sess.graph)
    print(sess.run(c))

writer.close()
sess.close()

我看到在 'C:/tensorlogs' 文件夹中创建了一个名为:'events.out.tfevents.1563219145.DESKTOP-5HG12IB'

的日志文件

我还可以在单​​独的浏览器中看到 tensorboard 运行ning window。在 'scaler' 页面上,它列出了正确的源文件夹 'C:/tensorflow'。

但是 tensorboard 表明没有会话 运行ning。

我做错了什么? 有什么方法可以检查该日志文件是否合法?

Browser window showing tensorboard running - but not finding log file

(图表上也没有显示 window)

更新:我尝试从命令行 运行 tensorboard 使用:

tensorboard --logdir='c:/tensorlogs' --port=6006

它具有相同的行为.. 页面在浏览器中显示没有数据。终端显示以下消息:

TensorBoard 1.13.1 在 http://DESKTOP-5HG12IB:6006(按 CTRL+C 退出) I0716 06:56:05.074265 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/experiments HTTP/1。 1[0 米" 200 - I0716 06:56:05.086722 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/environment HTTP/1。 1[0 米" 200 - I0716 06:56:05.088708 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/plugins_listing HTTP/1。 1[0 米" 200 - I0716 06:56:05.090195 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/runs HTTP/1。 1[0 米" 200 - I0716 06:56:05.099200 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:05] "[37mGET /data/plugin/scalars/tags HTTP/1。 1[0 米" 200 - I0716 06:56:13.198990 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:13] “[37mGET / HTTP/1.1[0m” 200 - I0716 06:56:14.169489 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/editedexample.png HTTP/1.1[0米" 200 - I0716 06:56:14.170989 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/distance.png HTTP/1.1[0米" 200 - I0716 06:56:14.174491 3780 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/pdplots.png HTTP/1.1[0米" 200 - I0716 06:56:14.176498 12340 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /tf-interactive-inference-dashboard/explorecounterfactuals.png HTTP/1.1[0米" 200 - I0716 06:56:14.281985 12876 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /data/experiments HTTP/1。 1[0 米" 200 - I0716 06:56:14.282483 8400 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] “[37mGET /data/runs HTTP/1。 1[0 米" 200 - I0716 06:56:14.282483 12340 _internal.py:122] ::1 - - [16/Jul/2019 06:56:14] "[37mGET /data/environment HTTP/1。 1[0 米" 200 - ..还有更多...

您可能不了解 tensorboard 的基础知识,所以让我解释一下。 您创建了一个图形,并将其记录到一个文件中。您的日志文件将包含的唯一内容是带有单个运算符 (Add) 和两个输入的图形。

记录标量通常用于在训练神经网络时跟踪损失函数,this seems like a decent guide

编辑

1) 您确定 tensorboard 的路径正确吗?您可以转到终端中的日志文件夹,然后从那里 运行 tensorboard --logdir ./ 吗?

2) 尝试使用“”,我尝试使用以下命令:

tensorboard --logdir ./
tensorboard --logdir="./"
tensorboard --logdir='./'

最下面的一个在浏览器中出现错误,什么都不显示,其他两个工作正常。 ./ 应该可以用任何文件夹替换,我只是更喜欢在 windows 上进入我的终端文件夹,以防止任何路径中断

3) 你玩过 tensorflow 安装吗,你的 tensorboard 可能与你的 tensorflow 不完全兼容?您是否尝试过卸载每个 tensorboard / tensorflow 软件包,然后重新安装它们?这些是我的版本:

tensorboard==1.13.1
tensorflow==1.13.1
上面的

T.Kelher 提供了实现此功能的关键信息。我添加此注释只是为了帮助其他人解决同样的问题:

  1. 我完全 re-built 我的 anaconda 环境 运行ning tensorFlow GPU .. 几个网页建议这可以解决我看到的问题。

  2. 我的原始代码确实生成了正确的输出文件。我看到的错误是 tensorBoard 不是 运行ning,或者它在错误的文件夹中寻找日志文件

  3. 来自 TensorBoard 的一条错误消息尤其具有误导性。以下消息似乎不仅在没有日志文件时发出..而且在 tensorboard 未查找正确位置并且实际上找不到该位置时发出:

    在 logdir“[您命名的日志文件夹]”中找不到事件文件

  4. tensorBoard 无法在 Windows 上找到您的文件夹的原因之一是存在语法重载。 "C:/logfolder" 之类的东西可能会将 "C:" 解释为 运行 的标签而不是驱动器号。有人建议 ( https://github.com/tensorflow/tensorflow/issues/7856 ) 你可以使用 "training:c:/logfolder" 但我没有成功。

  5. 最后,根据 t.Kelher 的建议,我通过 (a) 运行 tensorBoard 不是来自 Jupter 内部,而是来自终端 window (b) 在启动 tensorBoard 之前进入日志文件夹 (c) 使用命令:

    tensorboard --logdir=./ --port=6006

(d) 而不是使用 URL: http://localhost:6006, using the URL..exactly as displayed by tensorBoard on startup .... http://[my 机器名]:6006