vis4d.op.loss.multi_level_seg_loss

Multi-level segmentation loss.

Classes

MultiLevelSegLoss([reducer, feature_idx, ...])

Multi-level segmentation loss class.

class MultiLevelSegLoss(reducer=<function mean_loss>, feature_idx=(0, ), weights=None)[source]

Multi-level segmentation loss class.

Applies the segmentation loss function to multiple levels of predictions to provide auxiliary losses for intermediate outputs in addition to the final output, used in FCN.

Creates an instance of the class.

Parameters:
  • reducer (LossReducer) – Reducer for the loss function. Defaults to mean_loss.

  • feature_idx (tuple[int]) – Indices for the level of features to compute losses. Defaults to (0,).

  • weights (list[float], optional) –

    The weights of each feature level. If None passes, it will set to 1 for all levels. Defaults to

    None.

forward(outputs, target, ignore_index=255)[source]

Forward pass.

Parameters:
  • outputs (list[Tensor]) – Multi-level outputs.

  • target (Tensor) – Assigned segmentation target mask.

  • ignore_index (int) – Ignore class id. Default to 255.

Returns:

Computed losses for each level.

Return type:

LossesType