Skip to content

Instantly share code, notes, and snippets.

@GitHubEmploy
Created December 30, 2021 21:17
Show Gist options
  • Save GitHubEmploy/4a05c6158305eeccea1f90372750bb49 to your computer and use it in GitHub Desktop.
Save GitHubEmploy/4a05c6158305eeccea1f90372750bb49 to your computer and use it in GitHub Desktop.
with torch.no_grad():
correct = 0
total = 0
for images, labels in test_loader:
images = images.to(device)
labels = labels.to(device)
outputs = model(images)
_, predicted = torch.max(outputs.data, 1)
total += labels.size(0)
correct += (predicted == labels).sum().item()
print('Accuracy of the network on the MNIST test images: {} %'.format(100 * correct / total))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment