We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d053113 commit 99158fdCopy full SHA for 99158fd
1 file changed
tutorial-contents/502_GPU.py
@@ -70,8 +70,8 @@ def forward(self, x):
70
# !!!!!!!! Change in here !!!!!!!!! #
71
pred_y = torch.max(test_output, 1)[1].cuda().data.squeeze() # move the computation in GPU
72
73
- accuracy = torch.sum(pred_y == test_y) / test_y.size(0)
74
- 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)
75
76
77
test_output = cnn(test_x[:10])
0 commit comments