我正在尝试创建一个MNIST分类器,但我无法弄清楚如何实际打印输出。
我正在运行以下代码,但是收到错误:
#pick random number
num = np.random.randint(0, mnist.test.images.shape[0])
img = mnist.test.images[num]
img = np.array(img, dtype='float')
pixels = img.reshape((28, 28))
plt.imshow(pixels, cmap='gray')
plt.show()
#format the image
inp = np.asarray(img)
inp = np.transpose(inp)
image = np.expand_dims(inp, axis=0) # shape : (1, 784)
image = np.float32(image)
out = predict(image, parameters)
print("Prediction forward propagation successful!")
print("Prediction: ")
with tf.Session() as sess:
print(sess.run(out)) #This line is giving me an error.
我是TensorFlow的新手,所以非常感谢任何帮助!