-
Notifications
You must be signed in to change notification settings - Fork 36
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
cleaning and reorganizing fuse core code on segmentation #318
Conversation
fuse/dl/losses/loss_focalLoss.py
Outdated
|
||
|
||
class WeightedFocalLoss(nn.Module): | ||
"Non weighted version of Focal Loss" |
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.
non-weighted or weighted?
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.
waiting to decide if to keep it or not
fuse/dl/losses/loss_focalLoss.py
Outdated
self.alpha = torch.tensor([alpha, 1 - alpha]) | ||
self.gamma = gamma | ||
|
||
def forward(self, inputs: Tensor, targets: Tensor) -> Tensor: |
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.
Why don't you get batch_dict instead of tensors?
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.
waiting to decide if to keep it or not
fuse/dl/losses/loss_focalLoss.py
Outdated
self.alpha = torch.tensor([alpha, 1 - alpha]) | ||
self.gamma = gamma | ||
|
||
def forward(self, inputs: Tensor, targets: Tensor) -> Tensor: |
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.
Add comments specifying which tensors do you expect, shape and content
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.
waiting to decide if to keep it or not
fuse/dl/losses/loss_focalLoss.py
Outdated
return result | ||
|
||
|
||
class WeightedFocalLoss(nn.Module): |
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.
Why did you move it? Are you using it?
If not, let's delete it. It's old code.
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 just think focal loss is not specific for segmentation, and we don't have it anywhere else in fuse so I moved it out of segmentation folder
@@ -44,7 +42,7 @@ def make_one_hot(input: Tensor, num_classes: int) -> Tensor: | |||
|
|||
|
|||
class BinaryDiceLoss(nn.Module): | |||
def __init__(self, power: int = 1, eps: float = 1.0, reduction: str = "mean"): | |||
def __init__(self, eps: float = 1e-5, reduction: str = "mean"): |
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.
Why did you change the defaults?
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.
remove power also from comments
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 think that the epsilon for smoothing should be small number and not 1.
I see in monai the number is 1e-5, do you have any other reference besides @egozi old code to keep it 1??
No description provided.