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

@ -97,7 +97,7 @@ for epoch in range(EPOCH):
if step % 50 == 0:
test_output = rnn(test_x) # (samples, time_step, input_size)
pred_y = torch.max(test_output, 1)[1].data.numpy().squeeze()
accuracy = sum(pred_y == test_y) / test_y.size
accuracy = sum(pred_y == test_y) / float(test_y.size)
print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)
# print 10 predictions from test data