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

Dice loss is weird? #16

Open
hdnminh opened this issue Dec 27, 2023 · 0 comments
Open

Dice loss is weird? #16

hdnminh opened this issue Dec 27, 2023 · 0 comments

Comments

@hdnminh
Copy link

hdnminh commented Dec 27, 2023

Hi @rezazad68

I hope you have a great last week of the year!

Can you explain your implemented dice loss:

    def _dice_loss(self, score, target):
        target = target.float()
        smooth = 1e-5
        intersect = torch.sum(score * target)
        y_sum = torch.sum(target * target)
        z_sum = torch.sum(score * score)
        loss = (2 * intersect + smooth) / (z_sum + y_sum + smooth)
        loss = 1 - loss
        return loss

Why are y_sum and z_sum calculated by square of target and score tensor, respectively? Following the formula, we just sum it basically without squaring itself.

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

No branches or pull requests

1 participant