This commit is contained in:
Morvan Zhou
2017-06-11 15:49:22 +10:00
committed by Morvan Zhou
parent d6f7fbf4cf
commit 3fc6f4e4a0
3 changed files with 3 additions and 3 deletions

View File

@ -98,7 +98,7 @@ for epoch in range(EPOCH):
if step % 50 == 0:
test_output = cnn(test_x)
pred_y = torch.max(test_output, 1)[1].data.squeeze()
accuracy = sum(pred_y == test_y) / test_y.size(0)
accuracy = sum(pred_y == test_y) / float(test_y.size(0))
print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)