Skip to content

Commit c66593f

Browse files
authored
fix accuracy bug
1 parent 4ef2d4d commit c66593f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mnist/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test():
100100
output = model(data)
101101
test_loss += F.nll_loss(output, target, size_average=False).data[0] # sum up batch loss
102102
pred = output.data.max(1, keepdim=True)[1] # get the index of the max log-probability
103-
correct += pred.eq(target.data.view_as(pred)).cpu().sum()
103+
correct += pred.eq(target.data.view_as(pred)).long().cpu().sum()
104104

105105
test_loss /= len(test_loader.dataset)
106106
print('\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\n'.format(

0 commit comments

Comments
 (0)