From ee79453f2e9494b54ca2ad74c80fbac9689a4d46 Mon Sep 17 00:00:00 2001 From: Cold2Point Date: Fri, 17 May 2019 15:15:06 +0800 Subject: [PATCH] Update 402_RNN_classifier.py --- tutorial-contents/402_RNN_classifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial-contents/402_RNN_classifier.py b/tutorial-contents/402_RNN_classifier.py index 3bb8231..0810b4c 100644 --- a/tutorial-contents/402_RNN_classifier.py +++ b/tutorial-contents/402_RNN_classifier.py @@ -95,7 +95,7 @@ def forward(self, x): if step % 50 == 0: test_output = rnn(test_x) # (samples, time_step, input_size) pred_y = torch.max(test_output, 1)[1].data.numpy() - accuracy = float((pred_y == test_y).astype(int).sum()) / float(test_y.size) + accuracy = float((pred_y == test_y.data.numpy()).astype(int).sum()) / float(test_y.size(0)) print('Epoch: ', epoch, '| train loss: %.4f' % loss.data.numpy(), '| test accuracy: %.2f' % accuracy) # print 10 predictions from test data