sigmoid_focal_loss

dragon.vm.torch.nn.functional.sigmoid_focal_loss(
  input,
  target,
  alpha=0.25,
  gamma=2.0,
  weight=None,
  size_average=None,
  negative_index=None,
  reduce=None,
  reduction='valid'
)[source]

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

The FocalLoss function is defined as:

\[\text{FocalLoss}(p_{t}) = -(1 - p_{t})^{\gamma}\log(p_{t}) \]
Parameters:
  • input (dragon.vm.torch.Tensor) – The input tensor.
  • target (dragon.vm.torch.Tensor) – The target tensor.
  • 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.
  • weight (dragon.vm.torch.Tensor, optional) – The weight for each class.
  • size_average (bool, optional) – Whether to average the loss.
  • negative_index (int, optional) – The negative label index.
  • reduce (bool, optional) – Whether to reduce the loss.
  • reduction ({'none', 'mean', 'sum', 'valid'}, optional) – The reduce method.
Returns:

dragon.vm.torch.Tensor – The output tensor.