Skip to content

Conversation

LucasFidon
Copy link
Contributor

Fixes #115 Port focal loss .

Description

Add an implementation of the Focal loss.

Status

Ready

Types of changes

  • New functionality added
  • Added unit tests for the new functionality

Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR @LucasFidon!

the unit tests look great, after merging this I'll populate the tests to all segmentation losses.

a few minor changes needed:

  • append this doc section to docs/source/losses.rst
`FocalLoss`
~~~~~~~~~
.. autoclass:: monai.losses.focal_loss.FocalLoss
    :members:

t = t.unsqueeze(2) # N,1 => N,1,1

# Compute the log proba (more stable numerically than softmax)
logpt = F.log_softmax(i, dim=1) # N,C,H*W
Copy link
Contributor

@wyli wyli May 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sigmoid formulation is for binary classification I think.

@wyli
Copy link
Contributor

wyli commented May 7, 2020

/black

@wyli wyli merged commit 5fcbf5a into Project-MONAI:master May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port focal loss
4 participants