contraction_net.losses
Classes
A combination of Binary Cross Entropy (BCE) and Dice Loss for binary segmentation tasks. |
|
Computes the smoothness loss for a sequence of predictions. |
Functions
|
Computes the F1 score for binary classification. |
Module Contents
- class contraction_net.losses.BCEDiceLoss(loss_params=(1, 1))[source]
Bases:
torch.nn.Module
A combination of Binary Cross Entropy (BCE) and Dice Loss for binary segmentation tasks.
- Parameters:
loss_params (tuple, optional) – A tuple containing the weights for BCE and Dice losses respectively. Default is (1, 1).
- bce_loss
- loss_params = (1, 1)
- class contraction_net.losses.SmoothnessLoss(alpha=10)[source]
Bases:
torch.nn.Module
Computes the smoothness loss for a sequence of predictions.
- Parameters:
alpha (float, optional) – Weight of the smoothness loss component. Default is 10.
- alpha = 10
- contraction_net.losses.f1_score(logits, true_labels, threshold=0.5, epsilon=1e-07)[source]
Computes the F1 score for binary classification.
- Parameters:
logits (torch.Tensor) – The raw output from the model (before applying sigmoid).
true_labels (torch.Tensor) – The ground truth binary labels.
threshold (float, optional) – The threshold to convert probabilities to binary predictions. Default is 0.5.
epsilon (float, optional) – A small value to avoid division by zero. Default is 1e-7.
- Returns:
The computed F1 score.
- Return type:
float