2017-08-24 28 views
1

を供給するとき、私はこのプレースホルダがありますTensorFlow InvalidArgumentErrorプレースホルダ

__y = tf.placeholder(tf.int32) 

をそして私は、次のコードでそれを使用します。

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}) 

そして、私はこのエラーを取得する:

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"]()]] 

私は私が得るエラーを理解していないので、私は私の問題を解決することができません。誰かが私に少なくとも何が起こっているか説明できますか?

答えて

0

問題が愚かだった、私は摂食されませんでした__y:

not_important, c = self.session.run([optimizer, self.cost], feed_dict={self.__labels: label, self.__y: 3.0}) 
0

私のようにあなたの例を書き換えた場合:ここでの問題は、あなたが「__y」の明示的な名前を提供しなかったとしてがいるということである

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"]()]] 

import tensorflow as tf 

__y = tf.placeholder(tf.int32) 

with tf.Session() as session: 
    session.run(__y) 

私は同じエラーを達成デフォルト名「プレースホルダ」を得て、それを供給する必要があり、次のように:

with tf.Session() as session: 
    print(session.run(__y, feed_dict={__y: 123})) 
関連する問題