Skip to content

Focal loss function conflicts with document information when performing binary classification! #2670

Open
@ABCnutter

Description

@ABCnutter

Thanks for your error report and we appreciate it a lot.

Checklist

1.Binary split out_ There is a conflict with Focal loss when channel=1!

Describe the bug

When performing binary segmentation, the official document suggests two processing methods:

① Set out_ Channels=2, use Cross Entropy Loss as the loss function during training, use F.softmax() to normalize the logits value during reasoning, and then use argmax() to get the prediction result of each pixel

② Set out_ Channels=1, take Binary Cross Entropy Loss as the loss function during training, use F.sigmoid() and threshold to get the prediction result during reasoning, and the threshold is 0.3 by default

When using the second method (out_channels=1), an error will occur if Focal loss is used!

Bug fix

When using Focal loss function for binary segmentation, out_ Channels needs to be set to 2, or modify the focal loss source code and add num_ classes、out_ The part of channels discrimination

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions