Hi there.  I have a problem.
I want to show my images for the purpose of knowing precision and recall.
However, my images can’t be loaded by imshow.
I think images and imshow are mismatch.
so,I want to fix my problem.

dataiter = iter(testloader)
for data in dataiter:
images, labels = data
print (images.shape)
imshow(torchvision.utils.make_grid(images, nrow=5))
images, labels = images.to(device), labels.to(device)

outputs = net(images)
_, predicted = torch.max(outputs.data, 1)
print(predicted)

print('Correct : ', ' '.join('%5s' % classes[labels[j]] for j in range(4)))
print('Predcit  : ', ' '.join('%5s' % classes[predicted[j]] for j in range(4)))
print(predicted==labels)


torch.Size([4, 3, 255, 255])



TypeError                                 Traceback (most recent call last)
 in ()
3     images, labels = data
4     print (images.shape)
----> 5     imshow(torchvision.utils.make_grid(images, nrow=5))
6
7 #     images, labels = images.to(device), labels.to(device)
/opt/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, hold, data, **kwargs)
3203                         filternorm=filternorm, filterrad=filterrad,
3204                         imlim=imlim, resample=resample, url=url, data=data,
-> 3205                         **kwargs)
3206     finally:
3207         ax._hold = washold
/opt/anaconda3/lib/python3.6/site-packages/matplotlib/init.py in inner(ax, *args, **kwargs)
1853                         “the Matplotlib list!)” % (label_namer, func.name),
1854                         RuntimeWarning, stacklevel=2)
-> 1855             return func(ax, *args, **kwargs)
1856
1857         inner.doc = _add_data_doc(inner.doc,
/opt/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5485                               resample=resample, **kwargs)
5486
-> 5487         im.set_data(X)
5488         im.set_alpha(alpha)
5489         if im.get_clip_path() is None:
/opt/anaconda3/lib/python3.6/site-packages/matplotlib/image.py in set_data(self, A)
651         if not (self._A.ndim == 2
652                 or self._A.ndim == 3 and self._A.shape[-1] in [3, 4]):
–> 653             raise TypeError(“Invalid dimensions for image data”)
654
655         if self._A.ndim == 3:
TypeError: Invalid dimensions for image data