Hi Yuri!



 yuri:

It is obvious why CrossEntropyLoss() only accepts Long type targets.


As of pytorch version 1.10, CrossEntropyLoss will accept either integer
class labels (torch.int64) or per-class probabilities (torch.float32
or torch.float64) as its target.


however, I ran it on Pycharm IDE with float type targets and it worked!!
…
The same example raised an error on Colab.


I assume that your pycharm platform was using pytorch 1.10 or later
while colab was using a version prior to 1.10.  You could probe this by
printing out torch.__version__ on both platforms.
(Using probabilistic (so-called "soft’) labels with CrossEntropyLoss is a
perfectly reasonable thing to do, and it’s nice that pytorch now supports
this directly.)
Best.
K. Frank