I encountered the problem as shown in the following pic:
When I tried to change loss.data[0] to loss.item(), but encountered another problem, error message is shown as follows:
How can I solve this, thank you very much.
I believe loss
is a tensor, thus to detach data
from tensor you should use loss[0].data