Keras: How to display RGB image (e.g. cifar) in Keras?

Created on 7 Dec 2015  路  2Comments  路  Source: keras-team/keras

Most helpful comment

Well.. I got the problem of dimensions from matplotlib:

TypeError: Invalid dimensions for image data

Because I directly use 'imshow' the image from cifar with shape(3,32,32), so the solution to solve it is to 'transpose' it.

plt.imshow(x.transpose(1,2,0)) #(height,width,dim)

All 2 comments

See #1161. For RGB, resize your vector to have shape (width, height, 3).

Well.. I got the problem of dimensions from matplotlib:

TypeError: Invalid dimensions for image data

Because I directly use 'imshow' the image from cifar with shape(3,32,32), so the solution to solve it is to 'transpose' it.

plt.imshow(x.transpose(1,2,0)) #(height,width,dim)
Was this page helpful?
0 / 5 - 0 ratings