-
Here is my attempt to handle missing ground truth data: focal_loss = monai.losses.FocalLoss()
def my_loss(output, target):
# skip overall QA, SNR and CNR
loss = 0
for i in range(3, 13):
i_target = target[..., i]
if i_target != -1:
i_output = output[..., i]
loss += focal_loss(i_output, i_target)
# if truth is -1 then ignore difference because ground truth was missing
return loss
...
# within training loop
outputs = model(inputs)
loss = my_loss(outputs, info) But I get an exception:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @yiheng-wang-nv , Could you please help share some comments about this question? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
What are the shapes of |
Beta Was this translation helpful? Give feedback.
-
Adding a dummy dimension gets me past the crash: i_output2 = i_output.unsqueeze(0)
i_target2 = i_target.unsqueeze(0)
loss += focal_loss(i_output2, i_target2) |
Beta Was this translation helpful? Give feedback.
Adding a dummy dimension gets me past the crash: