If you’re using CrossEntropyLoss, your target (label) should be a LongTensor. It varies based on the loss function. For example, for MSELoss, your target (label) should have the same type as your input.
To convert any tensor t to a LongTensor, you can do t.long().