Thank you for your reply. But I don’t think it works, it raised an error:
RuntimeError: multi-target not supported at d:\downloads\pytorch-master-1\torch\lib\thnn\generic/ClassNLLCriterion.c:20
I think it is because I unsqueezed the target, and torch regards it as a muti-target.
And after using unsqueeze, I printed the output.size() and target.size(), and got torch.Size([1, 1139]), torch.Size([1, 1139]), respectively.