mednet.models.segment.losses¶
Specialized losses for semanatic segmentation.
Classes
Calculates the binary cross entropy loss for every batch. |
|
Weighted Binary Cross-Entropy Loss for multi-layered inputs. |
|
Implement Equation 3 in [IGLOVIKOV-2018] for the multi-output networks. |
|
|
Implement the generalized loss function of Equation (3) at [IGLOVIKOV-2018]. |
- class mednet.models.segment.losses.BCEWithLogitsLossWeightedPerBatch[source]¶
Bases:
ModuleCalculates the binary cross entropy loss for every batch.
This loss is similar to
torch.nn.BCEWithLogitsLoss, except it updates thepos_weight(ratio between negative and positive target pixels) parameter for the loss term for every batch, based on the accumulated taget pixels for all samples in the batch.Implements Equation 1 in [MANINIS-2016]. The weight depends on the current proportion between negatives and positives in the ground- truth sample being analyzed.
- class mednet.models.segment.losses.SoftJaccardAndBCEWithLogitsLoss(alpha=0.7)[source]¶
Bases:
ModuleImplement the generalized loss function of Equation (3) at [IGLOVIKOV-2018].
At the paper, authors suggest a value of \(\alpha = 0.7\), which we set as default for instances of this type.
\[L = \alpha H + (1-\alpha)(1-J)\]J is the Jaccard distance, and H, the Binary Cross-Entropy Loss. Our implementation is based on
torch.nn.BCEWithLogitsLoss.- Parameters:
alpha (
float) – Determines the weighting of J and H. Default:0.7.
- class mednet.models.segment.losses.MultiLayerBCELogitsLossWeightedPerBatch[source]¶
Bases:
BCEWithLogitsLossWeightedPerBatchWeighted Binary Cross-Entropy Loss for multi-layered inputs.
This loss can be used in networks that produce more than one output that has to match output targets. For example, architectures such as as
hed.HEDorlwnet.LittleWNetrequire this feature.It follows the inherited super class applying on-the-fly pos_weight updates per batch.
- class mednet.models.segment.losses.MultiLayerSoftJaccardAndBCELogitsLoss(alpha=0.7)[source]¶
Bases:
SoftJaccardAndBCEWithLogitsLossImplement Equation 3 in [IGLOVIKOV-2018] for the multi-output networks.
This loss can be used in networks that produce more than one output that has to match output targets. For example, architectures such as as
hed.HEDorlwnet.LittleWNetrequire this feature.- Parameters:
alpha (float) – Determines the weighting of SoftJaccard and BCE. Default:
0.7.