1. Cross Entropy Loss CrossEntropyLoss
CrossEntropyLoss cross-entropy loss can be used for classification or segmentation tasks. Here we mainly introduce the segmentation tasks
Create the following data, pred is the predicted sample, label is the real label
In segmentation, if cross-entropy loss is used, it is necessary to ensure that the dimension of the label is 1 less than the dimension of pred, that is, there is no channel dimension. And, the type of label is int
The normal calculation loss result is:
Calculate manually, the softmax of pred is