为了想看一段代买的Tensor,加入了
sess = tf.Session()
print(sess.run(self.embedded_chars))
然后就报错:
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder_1' with dtype float
[[Node: Placeholder_1 = Placeholder[dtype=DT_FLOAT, shape=<unknown>, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
刚开始没找到错误,后来明白了。embedded_chars由两个量算得,但是都只定义了一个placeholder,没有赋值,所以得不到embedded_chars的值。例如(from https://github.com/tensorflow/tensorflow/issues/10632):
import tensorflow as tf
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = a + b
with tf.Session() as sess:
print(c.eval(feed_dict={a:1.0})) # I did not feed any value to
# `b` which is required for
# evaluating `c`
里面只定义了a,没有定义b的量,会产生同样的报错。