yhygao / CBIM-Medical-Image-Segmentation

A PyTorch framework for medical image segmentation
Apache License 2.0
260 stars 46 forks source link

About the weights for cross entropy loss #15

Closed dzzhang96 closed 1 year ago

dzzhang96 commented 1 year ago

Hi yhygao, thank you for the codes. I have seen you have used weight: [0.5, 1, 3] # weight of each class in the loss function when training the LITS datasets. I was now using my own datasets to segment the lung tumor. Can I ask for your experience if the weights are appropriate if I set it to [0.5, 2] or [0.5, 3]? Thanks again

yhygao commented 1 year ago

Hi, It depends on how imbalanced your dataset is. The model is more likely to predict it to be a tumor instead of a background if the weight is high. But false positives may happen. In my experience, this weight doesn't affect a lot if your training epoch is long enough. Both [0.5, 2] and [0.5, 3] should be ok. I can't say which is better, you'd better try it by yourself. I recommend you to visualize the segmentation maps to see how many are the false positive/negatives.

dzzhang96 commented 1 year ago

Thank you!