I am trying to display the image as:
figure = plt.figure()
num_of_images = 60
for index in range(1, num_of_images + 1):
    plt.subplot(6, 10, index)
    plt.axis('off')
    plt.imshow(images[index].numpy().transpose(1,2,0), cmap='gray_r')

I am facing the error:
TypeError                                 Traceback (most recent call last)
<ipython-input-35-f492e5cf63ef> in <module>()
      4     plt.subplot(6, 10, index)
      5     plt.axis('off')
----> 6     plt.imshow(images[index].numpy().transpose(1,2,0), cmap='gray_r')

5 frames
/usr/local/lib/python3.7/dist-packages/matplotlib/image.py in set_data(self, A)
    697                 or self._A.ndim == 3 and self._A.shape[-1] in [3, 4]):
    698             raise TypeError("Invalid shape {} for image data"
--> 699                             .format(self._A.shape))
    700 
    701         if self._A.ndim == 3:

TypeError: Invalid shape (28, 28, 1) for image data

The above format (28,28,1) is compliant with plt.show, then why I am facing this error?