没有张量板图 [英] there is no graph with tensorboard
问题描述
我正在阅读一本关于 Tensorflow 的书,我找到了这段代码:
I am reading a book on Tensorflow and I find this code:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
const1 = tf.constant(2)
const2 = tf.constant(3)
add_opp = tf.add(const1,const2)
mul_opp = tf.mul(add_opp, const2)
with tf.Session() as sess:
result, result2 = sess.run([mul_opp,add_opp])
print(result)
print(result2)
tf.train.SummaryWriter('./',sess.graph)
所以它非常简单,没什么特别的,它应该产生一些可以用张量板可视化的输出.
so it is very simple, nothing fancy and it is supposed to produce some output that can be visualized with tensorboard.
所以我运行脚本,它打印了结果,但显然 SummaryWriter 没有产生任何结果.
So I run the script, it prints the results but apparently SummaryWriter produces nothing.
我运行 tensorboard -logdir='./'
,当然没有图表.我可能做错了什么?
I run tensorboard -logdir='./'
and of course there is no graph.
What could I be doing wrong?
还有你如何终止张量板?我试过 ctrl-C 和 ctrl-Z 但它不起作用.(我也使用日文键盘,所以没有反斜杠以防万一)
And also how do you terminate tensorboard? I tried ctrl-C and ctrl-Z and it does not work. (also I am in a japanese keyboard so there is no backslash just in case)
推荐答案
tf.train.SummaryWriter
必须关闭(或刷新)以确保数据(包括图形)已写入其中.对您的程序进行以下修改应该可以工作:
The tf.train.SummaryWriter
must be closed (or flushed) in order to ensure that data, including the graph, have been written to it. The following modification to your program should work:
writer = tf.train.SummaryWriter('./', sess.graph)
writer.close()
这篇关于没有张量板图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!