Skip to content

Conversation

jaewoogwak
Copy link

I found some error

IndexError: invalid index of a 0-dim tensor. Use tensor.item() in Python or tensor.item<T>() in C++ to convert a 0-dim tensor to a number

Then I changed,

In train function,

loss.data.item() # loss.data[0] -> loss.data.item()

In test function,

test_loss += F.nll_loss(output, target, size_average=False).item() # .data[0] -> .item()

It works well

tensor.data -> tensor.item()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant