I am trying to see the images being loaded in the data loader. I used PIL in a custom loader to load the images. However, when I am using the following code to display images, I face the error:
images, labels = next(iter(test_loader))
plt.imshow( images )

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-35-d5057d4c4d54> in <module>()
      1 images, labels = next(iter(test_loader))
----> 2 plt.imshow( images )

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 (4, 3, 224, 224) for image data

What’s the reason behind this error?