lingvisa:

with torch.no_grad():
for data in testLoader:
images, labels = data


images and labels from your test dataset should be moved to device as well, i.e. images, labels = images.to(device), labels.to(device)
Same here



 lingvisa:

dataIter = iter(trainLoader)
images, labels = dataIter.next()
imshow(torchvision.utils.make_grid(images))
print('GroundTruth: ‘, ’ ‘.join(’%5s’ % classes[labels[j]] for j in range(4)))
outputs = net(images)


I may have missed something because of the formatting, but in general if your model is on one device (you did net.to(device)), you should move all inputs to that model to the same device.