vis4d.op.loss.seg_cross_entropy_loss

Segmentation cross entropy loss.

Classes

SegCrossEntropyLoss([reducer])

Segmentation cross entropy loss class.

class SegCrossEntropyLoss(reducer=<function mean_loss>)[source]

Segmentation cross entropy loss class.

Wrapper for nn.CrossEntropyLoss that additionally clips the output to the target size and converts the target mask tensor to long.

Creates an instance of the class.

Parameters:

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

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

Forward pass.

Parameters:
  • output (list[Tensor]) – Model output.

  • target (Tensor) – Assigned segmentation target mask.

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

Returns:

Computed loss.

Return type:

LossesType