-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add distance based loss #178
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @anwai98
# Because it always interprets the first axis as channel, | ||
# and treats it differently (sums over it independently). | ||
# This will lead to a very large dice loss that dominates over everything else. | ||
fg_input, fg_target = input_[:, 0:1], target[:, 0:1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is crucial, if we don't keep the channels then the dice loss does wrong things.
return overall_loss | ||
|
||
|
||
class DiceBasedDistanceLoss(DistanceLoss): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I by accident tried this (using dice loss both for the foreground and distance loss term) and this seems to work really good. We should give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, noted!
@@ -27,7 +27,8 @@ def __init__( | |||
out_channels=1, | |||
use_sam_stats=False, | |||
use_mae_stats=False, | |||
encoder_checkpoint_path=None | |||
encoder_checkpoint_path=None, | |||
final_activation=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, it's not a good idea to hard-code the final activation to sigmoid. I updated this to use the same logic and syntax as in our U-Net implementation.
No description provided.