Как вывести значение выходного Tensor в TensorFlow?

Я пытаюсь сделать классификатор 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, поэтому любая помощь очень ценится!

0 ответов

Другие вопросы по тегам