According to the documentation 6, the target must have only one dimension and as much elements as the batch size. In your case:



 yaodonggggggg:

target = torch.empty(3,50,50, dtype=torch.long).random_(5)


You should have rather torch.empty(3, dtype=torch.long).random_(5).
More over, the input should have only 2 dimensions.