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

Negative loss value #36

Open
memani1 opened this issue Mar 3, 2022 · 3 comments
Open

Negative loss value #36

memani1 opened this issue Mar 3, 2022 · 3 comments

Comments

@memani1
Copy link

memani1 commented Mar 3, 2022

When I train this model with the default run command python train.py

I see negative loss values and 0 Dice coefficient value

loss for step: 622 = [-0.9068316221237183]
loss for step: 623 = [-0.9329317808151245]
loss for step: 624 = [-0.9376015663146973]
Best validation mean DSC: 0.000000

This code is using Torch 1.10 on Nvidia GPU with CUDA 11.
Is there something that needs fixing in the code (dataloader etc.)?

@vksastry
Copy link

vksastry commented Mar 10, 2022

This issue arises with scikit-image = 0.19.x. The older version of skimage.transform.resize function converts the inputs from uint8 to an output of float64 and normalizes it within the function. But in the latest it produces an output of uint8 itself and does not normalize. So additional normalization of the mask is required so that it values are contained with 0s and 1s instead of a value of 255.

@vksastry
Copy link

Suggested changes:

def normalize_mask(mask):
mask = mask / (np.max(mask))
return mask

self.volumes = [(normalize_volume(v), normalize_mask(m)) for v, m in self.volumes]

@hehuayi12138
Copy link

thanks!really useful !

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

3 participants