From 3e2d0b8a40799f979c86a29f79f6baf5c721af8e Mon Sep 17 00:00:00 2001 From: morvanzhou Date: Tue, 13 Nov 2018 10:26:34 +0800 Subject: [PATCH] update for new version of torch --- tutorial-contents-notebooks/502_GPU.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial-contents-notebooks/502_GPU.ipynb b/tutorial-contents-notebooks/502_GPU.ipynb index 37bdf0f..c85bf84 100644 --- a/tutorial-contents-notebooks/502_GPU.ipynb +++ b/tutorial-contents-notebooks/502_GPU.ipynb @@ -213,7 +213,7 @@ " # !!!!!!!! Change in here !!!!!!!!! #\n", " pred_y = torch.max(test_output, 1)[1].cuda().data.squeeze() # move the computation in GPU\n", "\n", - " accuracy = sum(pred_y == test_y) / test_y.size(0)\n", + " accuracy = torch.sum(pred_y == test_y).type(torch.FloatTensor) / test_y.size(0)\n", " print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)\n" ] },