Hi Nikiguo!



 nikiguo93:

“RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 ‘target’ in call to _thnn_nll_loss2d_forward”
…
criterion=MSELoss().cuda()


Somewhere in your code you are not actually using MSELoss
as your criterion (but rather, most likely, CrossEntropyLoss).


    # calculate loss
    loss = criterion(yhat, local_Y)



At this point print out type (criterion) before calling
loss = criterion(yhat, local_Y) to see what criterion
actually is.
Best.
K. Frank