update for new version of torch

This commit is contained in:
morvanzhou
2018-11-13 10:26:34 +08:00
parent 0f4219c72c
commit 3e2d0b8a40

View File

@ -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"
]
},