code-of-learn-deep-learning-with-pytorch icon indicating copy to clipboard operation
code-of-learn-deep-learning-with-pytorch copied to clipboard

Chapter_3_LogisticRegression_block15

Open bgbofficial opened this issue 6 years ago • 1 comments

change:

acc = (mask == y_data).sum().data[0] / y_data.shape[0] if (e + 1) % 200 == 0: print('epoch: {}, Loss: {:.5f}, Acc: {:.5f}'.format(e+1, loss.data[0], acc)) )

to

acc = (mask == y_data).sum().numpy() / y_data.size()[0] if (e + 1) % 200 == 0: print('epoch: {}, Loss: {:.5f}, Acc: {:.5f}'.format(e+1, loss.detach().numpy(), acc)

bgbofficial avatar Jul 04 '19 03:07 bgbofficial

change:

acc = (mask == y_data).sum().data[0] / y_data.shape[0] if (e + 1) % 200 == 0: print('epoch: {}, Loss: {:.5f}, Acc: {:.5f}'.format(e+1, loss.data[0], acc)) )

to

acc = (mask == y_data).sum().numpy() / y_data.size()[0] if (e + 1) % 200 == 0: print('epoch: {}, Loss: {:.5f}, Acc: {:.5f}'.format(e+1, loss.detach().numpy(), acc)

Thanks!

DrBugKiller avatar Dec 03 '19 13:12 DrBugKiller