1
我剛從tensorflow開始,我想在我自己的圖像上測試tensorflow的tutorial的訓練模型。這是我用來測試使用SoftMax迴歸模型在教程開始對我自己的形象代碼:如何在單張圖像上測試Deep MNIST for Experts代碼?
with open("three.jpeg", "rb") as f:
contents = f.read()
image = tf.image.decode_jpeg(contents, channels=1)
image_float = tf.image.convert_image_dtype(image, tf.float32)
resized_image = tf.image.resize_images(image_float, [28, 28])
resized_image = tf.reshape(resized_image, [784])
img = 1 - resized_image.eval()
classification = sess.run(tf.argmax(y, 1), feed_dict={x: [img]})
plt.imshow(img.reshape(28, 28), cmap=plt.cm.binary)
plt.show()
print ('NN predicted', classification[0])
其中的SOFTMAX功能,但不是爲多層卷積網絡正常工作。我想在這一行
classification = sess.run(tf.argmax(y, 1), feed_dict={x: [img]})
到y_conv
改變y
但它給了我這個錯誤:
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_2' with dtype float [[Node: Placeholder_2 = Placeholderdtype=DT_FLOAT, shape=, _device="/job:localhost/replica:0/task:0/cpu:0"]]
命名您的佔位符,然後它將很容易調試。 –