Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focal loss #325

Merged
merged 4 commits into from
May 7, 2020
Merged

Focal loss #325

merged 4 commits into from
May 7, 2020

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