【发布时间】:2017-04-20 09:48:12
【问题描述】:
我正在尝试在 tensorboard 上绘制一个简单的绘图,就像他们在主页上一样,如下所示:
import tensorflow as tf
import numpy as np
x = tf.placeholder('float',name='X')
y= tf.placeholder('float',name='y')
addition = tf.add(x,y)
with tf.Session() as sess:
for i in range(100):
var1= np.random.rand()
var2= np.random.rand()
print(var1,var2)
tf.summary.scalar('addition',sess.run(addition, feed_dict={x:var1,y:var2}))
writer = tf.summary.FileWriter('Graphs',sess.graph)
虽然我可以看到图表,但我看不到任何标量值。任何人都可以向我解释我在这里做错了什么吗? PS:我已经运行了所有官方示例并且它们都在工作,但我需要理解这个示例才能使用它。 谢谢你的帮助 !
更新
运行@dv3 代码后程序崩溃。这就是我得到的:
InvalidArgumentError: You must feed a value for placeholder tensor 'input/x-input' with dtype float
[[Node: input/x-input = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
During handling of the above exception, another exception occurred:
InvalidArgumentError Traceback (most recent call last)
<ipython-input-5-5cbd77e71936> in <module>()
14 var2= np.random.rand()
15 print(var1,var2)
---> 16 add, s_ = sess.run([addition, summary_op], feed_dict={x:var1,y:var2})
17 writer.add_summary(s_, i)
【问题讨论】:
-
请分享整个会话的代码,你是怎么运行的?
-
这是全部代码?
-
哦,抱歉,结构让我很困惑 - 我会发布为什么你没有看到任何图表..
标签: python tensorflow tensorboard