Model loss decreases but validation DICE is always 0 #1727
Replies: 5 comments 16 replies
-
Could you please help take a look at this question? I think you guys have much experience in model training. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Typically for Also for |
Beta Was this translation helpful? Give feedback.
-
The idea with applying sigmoid in the binary case is that we want to convert the logits to something as close to a binary segmentation as possible. Any negative values become background, positive become the segmentation. Softmax is applied in the channel dimension so that a particular pixel/voxel will have the largest value in the channel for the most likely category, applying argmax to this then gives you the segmentation image. If following our tutorials in the notebooks so that you have a similar setup with the loss isn't helping perhaps there's something wrong with the data you're feeding the metric. I would look at a validation batch with matplotlib to make sure the images are sensible since a score of exactly 0.5 looks to me like something's misconfigured with the validation data pipeline or something else data related. |
Beta Was this translation helpful? Give feedback.
-
Hello, My code: root_dir = "/Data/images/.nii.gz")) data_dict = [ train_files = data_dict[:-9] train_transforms = Compose( ################################################################################### val_ds = Dataset(data=val_files, transform=val_transforms) device = torch.device("cuda:0") loss_function = DiceLoss(include_background=True, to_onehot_y=True, softmax=True, squared_pred=True, reduction='mean', batch=False) ################################################################## max_epochs = 10000 for epoch in range(max_epochs):
print( |
Beta Was this translation helpful? Give feedback.
-
Hi @ericspod, apologize for direct tagging you in the post. I have a similar problem with binary segmentation. I am training UNETR on 2 segmentation tasks, spleen (MSD Task 09) and lung tumor (MSD Task 06). The validation dice score for the lung tumor task is always around 0.00xx and does not improve along the training (after 40 epochs, each epoch of 250 iterations with batch size of 6). The validation dice score for spleen task, though relatively small, shows sign of improvement across time. I wonder if it is because of the size of the object that makes it difficult for the model to converge. Because the size of the lung tumor is pretty small (the median is like 30x40x18) compared to the spleen. Are you aware of similar problems or any techniques to train under these circumstances? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
First of all, I'm pretty new to this so please let me know if there is anything I can provide in a better way.
I'm trying to train a segmentation model on whole-body PET/CT images. I've tried to implement the standard U-net model for this. The output should be just a simple background=0 and tumor=1 label. The problem I'm facing is that even though the training loss is declining, my validation dice score is just 0, and I can't for the love of god figure out what I'm doing wrong.
This is my entire script:
#!/usr/bin/env python3
Beta Was this translation helpful? Give feedback.
All reactions