What is the weight values mean in torch.nn.CrossEntropyLoss?

It just means the weight that you give to different classes. Basically, for classes with small number of training images, you give it more weight so that the network will be punished more if it makes mistakes predicting the label of these classes. For classes with large numbers of images, you give it small weight.

4 Likes