出现 Expected object of scalar type Long but got scalar type Int for argument #2 报错

        When I ran the code, there was an error in the title style. After searching on the Internet, I finally found out that it was a problem with the loss function CrossEntropyLoss(). The problem is that my input type is different, because the input type of the loss function should be long, so the modification method is shown in the figure below

 As shown in the figure, I only need to change my labels variable to long type, and the program can continue to run.

Guess you like

Origin blog.csdn.net/qq_45710342/article/details/121692260