vis4d.op.loss.cross_entropy

Cross entropy loss.

Functions

cross_entropy(output, target[, ...])

Cross entropy loss function.

Classes

CrossEntropyLoss([reducer, class_weights])

Cross entropy loss class.

class CrossEntropyLoss(reducer=<function mean_loss>, class_weights=None)[source]

Cross entropy loss class.

Creates an instance of the class.

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

  • class_weights (list[float], optional) – Class weights for the loss function. Defaults to None.

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

Forward pass.

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

  • target (Tensor) – Assigned segmentation target mask.

  • reducer (LossReducer, optional) – Reducer for the loss function. Defaults to None.

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

Returns:

Computed loss.

Return type:

Tensor

cross_entropy(output, target, class_weights=None, ignore_index=255)[source]

Cross entropy loss function.

Parameters:
  • output (Tensor) – Model output.

  • target (Tensor) – Assigned segmentation target mask.

  • class_weights (Tensor | None, optional) – Class weights for the loss function. Defaults to None.

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

Returns:

Computed loss.

Return type:

Tensor