Loss Functions
SemanticSeg4EO provides a comprehensive set of loss functions for both binary and multi-class segmentation. The loss function list automatically switches when you change the training mode.
Binary Mode Loss Functions
These losses are available when Mode = binary.
Loss Function |
Description |
|---|---|
|
Recommended default. Combination of Dice loss and Binary Cross-Entropy (50/50 weight). Handles both overlap quality and pixel-level accuracy. |
|
Combination of Focal loss and Dice loss. Best for strongly imbalanced datasets where the foreground class is rare. |
|
Standard Binary Cross-Entropy. Simple and fast. Works well for balanced classes. |
|
Pure Dice loss. Focuses entirely on region overlap. Insensitive to class imbalance. |
|
Focal loss. Down-weights easy examples and focuses on hard-to-classify pixels. Use with the Focal Gamma and Focal Alpha parameters. |
|
Tversky loss. Generalisation of Dice that allows control over the trade-off between false positives (alpha) and false negatives (beta). |
|
Combination of Focal and Tversky losses. Best for very imbalanced data where recall is critical. |
Multi-class Mode Loss Functions
These losses are available when Mode = multiclass.
Loss Function |
Description |
|---|---|
|
Recommended default. Combination of multi-class Dice and Cross-Entropy. Robust on most datasets. |
|
Combination of multi-class Focal loss and Dice loss. Good for imbalanced multi-class problems. |
|
Standard Cross-Entropy. Classic choice, works well for balanced classes. |
|
Multi-class Dice loss. Handles class imbalance well. |
|
Multi-class Focal loss. Focuses training on difficult examples. |
|
Multi-class Tversky loss. Control FP/FN balance with alpha and beta. |
|
Multi-class Focal + Tversky combination. |
|
Multi-loss combination. A weighted sum of Dice, Focal, and Cross-Entropy. |
Loss Function Parameters
The Advanced Parameters tab exposes tuning parameters for Focal and Tversky losses.
Focal Loss Parameters
Parameter |
Default |
Effect |
|---|---|---|
Focal Gamma γ |
2.0 |
Modulating factor. Higher values → more focus on difficult pixels (those close to the decision boundary). γ = 0 reduces to standard cross-entropy. |
Focal Alpha α |
0.25 |
Weight for the positive (foreground) class. Increase for highly imbalanced datasets (rare foreground). |
Tversky Loss Parameters
Parameter |
Default |
Effect |
|---|---|---|
Tversky Alpha (FP weight) |
0.3 |
Controls false positive penalty. Lower = more false positives tolerated = higher recall. |
Tversky Beta (FN weight) |
0.7 |
Controls false negative penalty. Higher = stronger penalty for missed detections = higher recall. |
Note
For Tversky loss: Alpha + Beta should sum to 1.0. The default values (0.3 + 0.7 = 1.0) bias the model towards recall, which is appropriate for rare class detection (e.g., small buildings, water bodies).
Choosing a Loss Function
Scenario |
Recommended loss |
|---|---|
Balanced binary dataset |
|
Imbalanced binary (rare foreground) |
|
Balanced multi-class |
|
Imbalanced multi-class (rare classes) |
|
Need high recall (few missed detections) |
|
Need high precision (few false positives) |
|
Auto-Conversion
When you switch the training mode between binary and multiclass, the
loss function dropdown automatically selects a sensible equivalent:
binary_dice_bce↔dice_cebinary_focal↔focalbinary_tversky↔tversky
You can always override this auto-selection manually.