Issue
I learned some data with tensorflow.
For the test, I saw the shape of the final result.
It was tensor of (1, 80, 80, 1).
I use matplotlib or PIL to do this,
I wanted to see the image after changing to a pie array.
But I could not change the tensor to numpy.
I could not do anything because of the session even if I used eval ().
There is no way to convert tensor to numpy.
Can I see the tensor as an image?
(mytensor1) # mytensor
arr = np.ndarray(mytensor1)
arr_ = np.squeeze(arr)
plt.imshow(arr_)
plt.show()
but there is error message: TypeError: expected sequence object with len >= 0 or a single integer
Solution
You can use squeeze function from numpy. For example
arr = np.ndarray((1,80,80,1))#This is your tensor
arr_ = np.squeeze(arr) # you can give axis attribute if you wanna squeeze in specific dimension
plt.imshow(arr_)
plt.show()
Now, you can easily display this image (e.g. above code, assuming you are using matplotlib.pyplot as plt
).
Answered By - talos1904
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.