ignore_index: ignore_index parameter in cross entropy loss [ignore_index of torch.nn.functional.cross_entropy] [default -100]

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

Guess you like

Origin blog.csdn.net/u013250861/article/details/131762635