Skip to content

lovasz

Lovász-Softmax loss.

Classes:

  • LovaszLoss –

    Lovász-Softmax loss: a smooth surrogate for the mean-IoU objective.

LovaszLoss

LovaszLoss(
    ignore_index: int = -1,
    classes: Literal["present", "all"] = "present",
    loss_weight: float = 1.0,
)

Bases: Module

Lovász-Softmax loss: a smooth surrogate for the mean-IoU objective.

Optimizes segmentation overlap directly, and is typically summed with cross-entropy. See The Lovász-Softmax loss.

Parameters:

  • ignore_index (int, default: -1 ) –

    Label value excluded from the loss.

  • classes (Literal['present', 'all'], default: 'present' ) –

    "present" averages only classes present in the targets; "all" averages every class.

  • loss_weight (float, default: 1.0 ) –

    Scalar multiplier applied to the loss.

Methods:

  • forward –

    Compute the loss from per-point logits \((N, C)\) and labels \((N,)\).

forward

forward(logits: Tensor, labels: Tensor) -> Tensor

Compute the loss from per-point logits \((N, C)\) and labels \((N,)\).