I have one numpy sized array. After doing the calculation in TensorFlow, I get the output tf.Tensor. I am trying to convert it to a 2 dimensional array and show it as an image.
If it were numpy ndarray, I would know how to do it as an image. But now it's a tensor!
Although I tried to tensor.eval()convert it to a numpy array, I got the error message "No session by default."
Can someone teach me how to show tensor as image?
... ...
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
for i in range(1):
sess.run(train_step, feed_dict={x: x_data.T, y_: y_data.T})
probability = tf.argmax(y,1);
sess.run(probability, feed_dict={x: x_test.T})
img_res = tf.reshape(probability,[len_y,len_x])
fig, ax = plt.subplots(ncols = 1)
ax.imshow(np.asarray(img_res.eval()))
plt.show()
... ...
source
share