Last active
May 8, 2018 19:06
-
-
Save johnolafenwa/eae9e79aeb3ab7647168aed9cdd65c07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test(): | |
model.eval() | |
test_acc = 0.0 | |
for i, (images, labels) in enumerate(test_loader): | |
if cuda_avail: | |
images = Variable(images.cuda()) | |
labels = Variable(labels.cuda()) | |
# Predict classes using images from the test set | |
outputs = model(images) | |
_, prediction = torch.max(outputs.data, 1) | |
test_acc += torch.sum(prediction == labels.data) | |
# Compute the average acc and loss over all 10000 test images | |
test_acc = test_acc / 10000 | |
return test_acc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment