cs230-stanford / cs230-code-examples

Code examples in pyTorch and Tensorflow for CS230
Other
3.79k stars 984 forks source link

modified loss as per new pytorch version #15

Open vganesh46 opened 5 years ago

vganesh46 commented 5 years ago

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/