如何在单张图像上测试Deep MNIST for Experts代码?
问题描述:
我刚从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"]]
答
有在图形中的占位符的地方,你不喂。赔率是你需要另一个x
在你的feed_dict,为另一个网络。
命名您的占位符,然后它将很容易调试。 –