Skip to content

Instantly share code, notes, and snippets.

@vinimonteiro
Created December 17, 2021 15:00
Show Gist options
  • Save vinimonteiro/74019351d42fff6c99a6d29366287795 to your computer and use it in GitHub Desktop.
Save vinimonteiro/74019351d42fff6c99a6d29366287795 to your computer and use it in GitHub Desktop.
nn_pytorch_validation
orrect = 0
total = 0
with torch.no_grad():
for data in testset:
data_input, target = data
output = model(data_input.view(-1, 784))
for idx, i in enumerate(output):
if torch.argmax(i) == target[idx]:
correct += 1
total += 1
print('Accuracy: %d %%' % (100 * correct / total))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment