torchcell.losses.multi_dim_nan_tolerant.CombinedOrdinalCELoss

class CombinedOrdinalCELoss(num_classes: int, num_tasks: int = 2, weights: Tensor | None = None)[source]

Bases: Module

Combined ordinal classification loss with dimension-wise weighting.

forward(logits: Tensor, targets: Tensor) → tuple[Tensor, Tensor][source]

Compute weighted ordinal classification loss.

Parameters:
  • logits – Model predictions [batch_size, num_tasks * num_classes]

  • targets – Target labels [batch_size, num_tasks * num_classes]

Returns:

(total_loss, dim_losses)

Return type:

tuple