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

The FocalLoss function is defined as:

\[\text{FocalLoss}(p_{t}) = -(1 - p_{t})^{\gamma}\log(p_{t}) \]
  • 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.

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