From 99158fd0ca952f211911ca26e548e88211c9d57e Mon Sep 17 00:00:00 2001 From: Jerome Date: Sat, 14 Jul 2018 22:35:34 +0800 Subject: [PATCH] Fixing error accurate and error tensor to numpy --- tutorial-contents/502_GPU.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial-contents/502_GPU.py b/tutorial-contents/502_GPU.py index 741587a..58cd07b 100644 --- a/tutorial-contents/502_GPU.py +++ b/tutorial-contents/502_GPU.py @@ -70,8 +70,8 @@ for epoch in range(EPOCH): # !!!!!!!! Change in here !!!!!!!!! # pred_y = torch.max(test_output, 1)[1].cuda().data.squeeze() # move the computation in GPU - accuracy = torch.sum(pred_y == test_y) / test_y.size(0) - print('Epoch: ', epoch, '| train loss: %.4f' % loss.data.numpy(), '| test accuracy: %.2f' % accuracy) + accuracy = torch.sum(pred_y == test_y).type(torch.FloatTensor) / test_y.size(0) + print('Epoch: ', epoch, '| train loss: %.4f' % loss.data.cpu().numpy(), '| test accuracy: %.2f' % accuracy) test_output = cnn(test_x[:10])