As the above still get’s likes:
Note that the above post is outdated.
Nowadays, with PyTorch >= 0.4 you have


loss the Tensor (which previously was the variable),

loss.data (shouldn’t be needed much anymore) which is roughly equivalent to loss.detach(), a Tensor which does not do tracing for derivatives anymore (you can use this to keep around but e.g. don’t want to move things off the GPU yet)

loss.item() the Python number contained in a 1-element tensor.

Best regards
Thomas