I have this placeholder:
__y = tf.placeholder(tf.int32)
And then I use it in the following code:
self.session.run(tf.global_variables_initializer())
self.cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=self.__y, logits=self.super_source))
opt = tf.train.GradientDescentOptimizer(0.1).minimize(self.cost)
not_important, c = self.session.run(opt, feed_dict={labels: label})
And I get this error:
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype int32
[[Node: Placeholder = Placeholder[dtype=DT_INT32, shape=<unknown>, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]
I don't understand the error that I get and so I cant solve my problem. Can someone explain me at least what's happening?
If I rewrite your example as:
import tensorflow as tf
__y = tf.placeholder(tf.int32)
with tf.Session() as session:
session.run(__y)
I achieve the same error:
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype int32
[[Node: Placeholder = Placeholder[dtype=DT_INT32, shape=<unknown>, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
The issue here is that as you did not provide an explicit name for '__y' is has gotten the default name 'Placeholder', so it should be fed as follows:
with tf.Session() as session:
print(session.run(__y, feed_dict={__y: 123}))
问题很愚蠢,我没喂__y:
not_important, c = self.session.run([optimizer, self.cost], feed_dict={self.__labels: label, self.__y: 3.0})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.