Advertisement
kimo12

Untitled

Mar 27th, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. # functions to show an image
  5.  
  6.  
  7. def imshow(img):
  8. img = img / 2 + 0.5 # unnormalize
  9. npimg = img.numpy()
  10. plt.imshow(np.transpose(npimg, (1, 2, 0)))
  11. plt.show()
  12.  
  13. dataiter = iter(testloader)
  14. images, labels = dataiter.next()
  15.  
  16. # print images
  17. imshow(torchvision.utils.make_grid(images))
  18. print('GroundTruth: ', ' '.join('%5s' % classes[labels[j]] for j in range(4)))
  19.  
  20. outputs = net(images)
  21.  
  22. _, predicted = torch.max(outputs, 1)
  23.  
  24. print('Predicted: ', ' '.join('%5s' % classes[predicted[j]]
  25. for j in range(4)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement