neuro_morpho.model.loss
Loss functions for training models.
Attributes
Classes
Weighted version of Focal Loss. |
|
Dice Loss for image segmentation for binary classification. |
|
Weighted Map Loss. |
|
Combined Loss Function. |
Module Contents
- neuro_morpho.model.loss.NAME_LOSS
- neuro_morpho.model.loss.PRED
- neuro_morpho.model.loss.TARGET
- neuro_morpho.model.loss.LOSS_FN
- class neuro_morpho.model.loss.WeightedFocalLoss(alpha: float = 0.25, gamma: float = 2, reduction: str = 'mean')
Bases:
torch.nn.ModuleWeighted version of Focal Loss.
This loss is designed to address class imbalance by down-weighting easy examples and focusing on hard examples.
See: https://arxiv.org/pdf/1708.02002
- Parameters:
- alpha = 0.25
- gamma = 2
- reduction = 'mean'
- class neuro_morpho.model.loss.SigmoidDiceLoss(smooth=1.0)
Bases:
torch.nn.ModuleDice Loss for image segmentation for binary classification.
This loss is commonly used for image segmentation tasks. It measures the overlap between the predicted and target segmentation.
- smooth = 1.0
- class neuro_morpho.model.loss.WeightedMap(loss_fn: torch.nn.Module, coefs: list[float])
Bases:
torch.nn.ModuleWeighted Map Loss.
This loss applies a weighted sum of a given loss function to a list of predictions and targets.
- coefs
- loss_fn
- class neuro_morpho.model.loss.CombinedLoss(weights: list[float], losses: list[torch.nn.Module])
Bases:
torch.nn.ModuleCombined Loss Function.
This loss function combines multiple loss functions with given weights.
- weights
- losses