code-of-learn-deep-learning-with-pytorch
code-of-learn-deep-learning-with-pytorch copied to clipboard
Chapter_3_LogisticRegression_block15
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)
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!