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

fix ignore index for DiceCEEdgeLoss #588

Merged
merged 1 commit into from
Dec 28, 2022

Conversation

lkdci
Copy link
Contributor

@lkdci lkdci commented Dec 28, 2022

Torch native cpp loss classes except only integer as ignore_index, the default is -100 for not using ignore.
While python based implementation use None as explicit indication for no using an ignore_index, see DiceLoss and torchmetrics.JaccardIndex class signatures.
This PR prevent passing an integer to DiceLoss that crash in the to_one_hot function due to an extra unnecessary ignore class, as follows:

  File "/home/lior.kadoch/PycharmProjects/super-gradients/src/super_gradients/training/losses/dice_loss.py", line 28, in _calc_numerator_denominator
    numerator = labels_one_hot * predict
RuntimeError: The size of tensor a (22) must match the size of tensor b (21) at non-singleton dimension 1

@dagshub
Copy link

dagshub bot commented Dec 28, 2022

Copy link
Collaborator

@ofrimasad ofrimasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ofrimasad ofrimasad merged commit f460027 into master Dec 28, 2022
@ofrimasad ofrimasad deleted the bugfix/SG-546_ignore_index_fix branch December 28, 2022 11:19
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.

2 participants