7

I am trying to learn how to use tensorboard and I would like to have it run in my program. I do not understand how to create a log directory. These are the lines I have for running tensorboard.

   summary_writer = tf.train.SummaryWriter('/tensorflow/logdir', sess.graph_def)
   tensorboard --logdir=tensorflow/logdir

The error message that I got was

Cannot assign to operator
4

2 回答 2

9

这条线需要在您的代码(python 脚本)中,就像您所说的那样:

summary_writer = tf.train.SummaryWriter('/tensorflow/logdir', sess.graph_def)

但是,这一行必须从 linux 调用(而不是从脚本中调用):

张量板 --logdir=tensorflow/logdir

但是,在 tensorboard 真正运行之前,您还需要做很多事情: 如何创建 Tensorflow Tensorboard Empty Graph

于 2016-05-10T16:26:00.730 回答
3

教程可能在TensorFlow官网上透露的不是很清楚

我以前遇到过同样的问题

但为了不让你迷惑,我还是用它作为指南

第一部分(.py 文件中的代码行)

只需跳到官方指南中的tf.train.SummaryWriter 类

首先,您需要 .py 文件中的这行代码来创建数据流图

在 tensorflow 中,会话是创建图形的地方

#...create a graph...
# Launch the graph in a session.
sess = tf.Session()

然后,您还需要在代码中输入这些行

# Create a summary writer, add the 'graph' to the event file.
writer = tf.train.SummaryWriter(< directory name you create>, sess.graph)

在你创建的 .py 文件执行后,会在你分配的目录中生成 logs 文件夹

是您可以使用的示例代码

第二部分(Linux 终端中的代码行)

在你的 Linux 终端窗口中,输入

tensorboard --logdir="path of your log file"

它将自动链接到您的日志文件

最后一步(在浏览器中输入链接)

键入后

tensorboard --logdir="path of your log file"

它将生成一个 http 链接,例如http://666.6.6.6:6006

将 http 链接复制到您的网络浏览器中

好好享受!

当心

在上面的代码行中键入之前不要进入日志文件所在的目录

它可能会错过日志文件

这个youtube 视频将在 9:40 更明确地解释这一点

您也可以在官方指南上查看如何启动 tensorboard

希望你能尽快展示你的数据图~

于 2016-11-29T08:42:02.553 回答