From 5d6d4f056e359beee64d22c53cbd76e95e67b45a Mon Sep 17 00:00:00 2001 From: keineahnung2345 Date: Tue, 13 Nov 2018 10:05:44 +0800 Subject: [PATCH] 502 - remove squeeze for 1-D tensor --- 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 58cd07b..383e5ba 100644 --- a/tutorial-contents/502_GPU.py +++ b/tutorial-contents/502_GPU.py @@ -68,7 +68,7 @@ for epoch in range(EPOCH): test_output = cnn(test_x) # !!!!!!!! Change in here !!!!!!!!! # - pred_y = torch.max(test_output, 1)[1].cuda().data.squeeze() # move the computation in GPU + pred_y = torch.max(test_output, 1)[1].cuda().data # move the computation in GPU 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) @@ -77,7 +77,7 @@ for epoch in range(EPOCH): test_output = cnn(test_x[:10]) # !!!!!!!! Change in here !!!!!!!!! # -pred_y = torch.max(test_output, 1)[1].cuda().data.squeeze() # move the computation in GPU +pred_y = torch.max(test_output, 1)[1].cuda().data # move the computation in GPU print(pred_y, 'prediction number') print(test_y[:10], 'real number')