Skip to content

Focal loss#325

Merged
wyli merged 4 commits intoProject-MONAI:masterfrom
LucasFidon:115-port-focal-loss
May 7, 2020
Merged

Focal loss#325
wyli merged 4 commits intoProject-MONAI:masterfrom
LucasFidon:115-port-focal-loss

Conversation

@LucasFidon
Copy link
Copy Markdown
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
Copy Markdown
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:

Comment thread monai/losses/focal_loss.py Outdated
Comment thread monai/losses/focal_loss.py Outdated
Comment thread monai/losses/focal_loss.py Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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