PyTorchZeroToAll icon indicating copy to clipboard operation
PyTorchZeroToAll copied to clipboard

Lec11 bug fixed

Open jaewoogwak opened this issue 1 year ago • 0 comments
trafficstars

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

jaewoogwak avatar Mar 23 '24 08:03 jaewoogwak