cs230-code-examples
cs230-code-examples copied to clipboard
modified loss as per new pytorch version
Before Pytorch 0.4.0., loss was a Variable wrapping a tensor of size (1,), but in 0.4.0 loss is now a scalar and has 0 dimensions. Indexing into a scalar doesn’t make sense (it gives a warning now, but will be a hard error in 0.5.0). Use loss.item() to get the Python number from a scalar.
https://pytorch.org/blog/pytorch-0_4_0-migration-guide/