I am anxious about this 'RuntimeError'

Traceback (most recent call last):

File “”, line 1, in
runfile(‘D:/360Downloads/VS/train.py’, wdir=‘D:/360Downloads/VS’)

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\spyder_kernels\customize\spydercustomize.py”, line 827, in runfile
execfile(filename, namespace)

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\spyder_kernels\customize\spydercustomize.py”, line 110, in execfile
exec(compile(f.read(), filename, ‘exec’), namespace)

File “D:/360Downloads/VS/train.py”, line 135, in
fit(epochs, model, loss_func, opt, train_dl, valid_dl)

File “D:/360Downloads/VS/train.py”, line 47, in fit
losses, nums = zip(*[loss_batch_train(model, loss_func, xb, yb, opt) for xb, yb in train_dl])

File “D:/360Downloads/VS/train.py”, line 47, in
losses, nums = zip(*[loss_batch_train(model, loss_func, xb, yb, opt) for xb, yb in train_dl])

File “D:/360Downloads/VS/train.py”, line 19, in loss_batch_train
loss = loss_func(model(xb), yb)

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\torch\nn\functional.py”, line 1970, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\torch\nn\functional.py”, line 1790, in nll_loss
ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)

RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 ‘target’

what shulde I do

From the error, it looks like “nll_loss” " Expected object of scalar type Long but got scalar type Int". So I guess you should change the input from an int Tensor to a long Tensor?