Reputation: 359
I try to plot Images with 100,100,1 but got an error like this
TypeError: Invalid shape (100, 100, 1) for image data
here is the code
sample_training_images, _ = next(traindata)
def plotImages(images_arr):
fig, axes = plt.subplots(1, 5, figsize=(20,20))
axes = axes.flatten()
for img, ax in zip( images_arr, axes):
ax.imshow(img)
ax.axis('off')
plt.tight_layout()
plt.plot(images_arr)
plt.show()
plotImages(sample_training_images[:5])
Upvotes: 3
Views: 10579
Reputation: 150735
Replace img
with img[:,:,0]
:
ax.imshow(img[:,:,0], cmap='gray')
And probably remove the plt.plot(images_arr)
Upvotes: 8