1
私はうまく動作するロジスティック回帰を実装しました。これは、精度を正しく出力します。私はそのように精度を表示します...テンソルフローを使用して正しい予測を印刷できません
# Test model
correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
# Calculate accuracy
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print("Accuracy:", accuracy.eval({x: mnist.test.images, y: mnist.test.labels}))
私が言ったように、これはうまくいきます。しかし、チュートリアルを読んだ後、correct_prediction
は、予測が真であるかどうかを示すブール値の配列になるはずです。私はこのブール値を印刷したいが、私は問題にぶつかる。
print(sess.run(correct_prediction))
>>>InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype float
[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
私はTensorFlowに非常に新しいです...私は、次の...
print(correct_prediction)
>>>Tensor("Equal:0", shape=(?,), dtype=bool)
を試してみましたが、その後、私が試してみました。この変数を予測の配列として出力するにはどうすればよいですか?