Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

New loss function for segmentation #200

Closed
fepegar opened this issue Aug 9, 2018 · 4 comments · Fixed by #201
Closed

New loss function for segmentation #200

fepegar opened this issue Aug 9, 2018 · 4 comments · Fixed by #201

Comments

@fepegar
Copy link
Collaborator

fepegar commented Aug 9, 2018

Hi all,

I have implemented the Tversky loss function for segmentation with imbalanced data. I'll try it tomorrow and if it works I'll open a PR.

It needs two parameters α and β to weight precision and recall during training (if α + β = 1, it's equivalent to an Fβ-score and if α = β = 0.5, it's Dice). Is there a way to specify those without hard-coding them? The only other losses that accept kwargs are GDSC and wasserstein_disagreement_map, but I the only example I've found in the repo in which those are passed is in this test:

def test_generalised_dice_score_uniform_regression(self):
with self.test_session():
predicted = tf.constant([[0, 10], [10, 0], [10, 0], [10, 0]],
dtype=tf.float32, name='predicted')
labels = tf.constant([[1, 0, 0, 0]], dtype=tf.int64, name='labels')
weights = tf.cast(labels, tf.float32)
predicted, labels, weights = [tf.expand_dims(x, axis=0) for x in
(predicted, labels, weights)]
test_loss_func = LossFunction(
2, loss_type='GDSC',
loss_func_params={'type_weight': 'Uniform'})
one_minus_generalised_dice_score = test_loss_func(
predicted, labels, weights)
self.assertAllClose(one_minus_generalised_dice_score.eval(),
0.3333, atol=1e-4)

@wyli
Copy link
Member

wyli commented Aug 9, 2018

Thanks @fepegar, the loss function's interface is ready, but we need the new configuration file #166 to support a proper nested parameter parsing.

Perhaps @BostonChildrensRadiology would be interested in this implementation as well.

@fepegar
Copy link
Collaborator Author

fepegar commented Aug 9, 2018

Cool, looking forward to the new config format.

I'll submit the PR as a WIP in a second.

@wyli wyli closed this as completed in #201 Aug 13, 2018
zhanghaoyue pushed a commit to zhanghaoyue/NiftyNet that referenced this issue Oct 18, 2019
Resolve "bilinear additive upsampling"

Closes NifTK#200

See merge request !165
@amartya-k
Copy link

Is this working for class imbalanced semantic segmentation?(mostly medical images)

@fepegar
Copy link
Collaborator Author

fepegar commented Nov 2, 2019

@amartya-k yes, it should. Take a look at the paper I referenced in the first comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants