Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. # Test the model
  2. # In test phase, we don't need to compute gradients (for memory efficiency)
  3. with torch.no_grad():
  4. correct = 0
  5. total = 0
  6. for images, labels in test_loader:
  7. images = images.to(device)
  8. labels = labels.to(device)
  9. outputs = model(images)
  10. _, predicted = torch.max(outputs.data, 1)
  11. total += labels.size(0)
  12. correct += (predicted == labels).sum().item()
  13.  
  14. print('Accuracy of the network on the MNIST test images: {} %'.format(100 * correct / total))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement