yamle.losses.segmentation module#

class yamle.losses.segmentation.SoftIntersectionOverUnionLoss(factor=1.0, ignore_indices=[], **kwargs)[source]#

Bases: BaseLoss

This defines the soft intersection over union loss for semantic segmentation.

It assumes that the input shape is (batch_size, num_members, num_classes, height, width). No matter what the reduction it is always averaged over the num_members.

The input is assumed to be probabilities.

The loss can also be weighted by a weight tensor of shape (batch_size).

Parameters:
  • factor (float) – The softness factor. Defaults to 1.0.

  • ignore_indices (List[int]) – The indices to ignore. Defaults to [].

static add_specific_args(parent_parser)[source]#

This method is used to add the loss specific arguments to the parent parser.

Return type:

ArgumentParser

class yamle.losses.segmentation.FocalLoss(alpha=0.25, gamma=2.0, ignore_indices=[], *args, **kwargs)[source]#

Bases: BaseLoss

This defines the focal loss for semantic segmentation.

It assumes that the input shape is (batch_size, num_members, num_classes, height, width). No matter what the reduction it is always averaged over the num_members.

The input is assumed to be probabilities.

The loss can also be weighted by a weight tensor of shape (batch_size).

Parameters:
  • alpha (float) – The alpha factor. Defaults to 0.25.

  • gamma (float) – The gamma factor. Defaults to 2.0.

  • ignore_indices (List[int]) – The indices to ignore. Defaults to [].

static add_specific_args(parent_parser)[source]#

This method is used to add the loss specific arguments to the parent parser.

Return type:

ArgumentParser