sigmoid_focal_loss

dragon.losses.sigmoid_focal_loss(
  inputs,
  axis=1,
  alpha=0.25,
  gamma=2.0,
  negative_index=None,
  reduction='valid',
  **kwargs
)[source]

Compute the sigmoid focal loss with sparse labels. [Lin et.al, 2017].

The Focal loss function is defined as:

\[\text{FocalLoss}(p_{t}) = -(1 - p_{t})^{\gamma}\log(p_{t}) \]
Parameters:
  • inputs (Sequence[dragon.Tensor]) – The tensor logit and label.
  • axis (int, optional, default=1) – The reduce axis, can be negative.
  • alpha (float, optional, default=0.25) – The scale factor on the rare class.
  • gamma (float, optional, default=2.) – The exponential decay factor on the easy examples.
  • negative_index (int, optional) – The negative class index.
  • reduction ({'none', 'sum', 'mean', 'valid'}, optional) – The reduction method.
Returns:

dragon.Tensor – The output tensor.