は、いくつかの問題は、以下のように発生しました:InvalidArgumentError(ソフトマックスmnist)
tensorflow.python.framework.errors_impl.InvalidArgumentError:
You must feed a value for placeholder tensor 'Placeholder_1' with dtype float [[Node: Placeholder_1 = Placeholderdtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]]
を説明以上のことから、私はこの問題は、引数の型エラーであることを理解しています。しかし、私のコードでは、データの型はプレースホルダと同じです。
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
m = input_data.read_data_sets("MNIST_data/", one_hot=True)
sess = tf.InteractiveSession()
x = tf.placeholder(tf.float32, [None, 784])
w = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.nn.softmax(tf.matmul(x, w)+b)
y_ = tf.placeholder(tf.float32, [None, 10])
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
tf.global_variables_initializer()
for i in range(1000):
batch_xs, batch_ys = m.train.next_batch(100)
train_step.run({x: batch_xs, y: batch_ys})
correct_prediction = tf.equal(tf.arg_max(y, 1), tf.arg_max(y_, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print(accuracy.eval({x: m.test.images, y: m.test.labels}))
私は問題がbatch_xs(のfloat32)とbatch_ys(のfloat32)の種類によって引き起こされると思います。
これを解決する方法についてのご意見はありますか?
に行を変更し、それは 'accuracy.eval'のcall.Thanks多くのfeed_dictにy'代わりy_''の '渡すために私のせいです。 –
あなたは大歓迎です!私の答えはあなたの問題を解決したので、 – nessuno