0

I have a multidimensional array (11, 28, 28) which consists of 11 images, each with 28*28 pixels.

x_train_new_reshaped[0].shape

Out[8]: (11, 28, 28)

How can I display them all at once?

This results in:

In:
image = x_train_new_reshaped[0]
plt.figure()
plt.imshow(image)
plt.show()


Out:
TypeError: Invalid dimensions for image data

This as well:

In:
image = np.squeeze(x_train_new_reshaped[0])
plt.figure()
plt.imshow(image)
plt.show()

Out:
TypeError: Invalid dimensions for image data

Any help is appreciated.

Audiogott
  • 95
  • 2
  • 12

1 Answers1

0

In case you want an image-plot as your code suggests, then the array should be 2D. Since you have multiple images stored in a 3D array, the easiest way would be to do a subplot for each image stored in your array and loop over them. With matplotlib you can find many examples how a subplot looks like, for example also here on stackoverflow: How do I get multiple subplots in matplotlib?

raef
  • 51
  • 2
  • 4