weight parameter of DiceCELoss #7522
Replies: 1 comment 2 replies
-
Hi @NastaranVB, please set the weight contain background; this will remove the background class internal. Because weight must also be used in 'CrossEntropyLoss'. Line 714 in e9e2738 Thanks. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am doing multi class segmentation which contains 3 classes including background. I want to consider weight parameter of "DiceCEloss", so have defined loss function as below:
loss_function=DiceCELoss(include_background=False, to_onehot_y=True, softmax=True, weight=torch.tensor([1, 10])).
I get the below error:
ValueError: the length of the
weight
sequence should be the same as the number of classes.If
include_background=False
, the weight should not includethe background category class 0.
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions