ContrastiveSeg icon indicating copy to clipboard operation
ContrastiveSeg copied to clipboard

about the decrease of the loss

Open hhxzzy opened this issue 2 years ago • 8 comments

Hello. Thanks for your excellent work! I transplant the loss function and memory bank of your code to my own code, and run my code on Cityscapes dataset and my own dataset. But it turns out that the decrease of the contrast loss is very small. For example, the contrast loss drops from 1.27 to 1.11 after 80k epoch on Cityscapes, while the ce loss drops from 1.26 to 0.15. And the same thing happens on my own dataset. It seems that the contrast loss is not being useful during train. I wonder is it normal for the contrast loss to decrease so little? And what can I do to make full use of the contrast loss, like tuning the hyper-parameters?

hhxzzy avatar Mar 01 '22 08:03 hhxzzy

I have the same problem too, looking forward to the author's answer

guwen007 avatar Mar 03 '22 08:03 guwen007

@hhxzzy I'm sorry to bother you.I added the contrast loss function to my model and code, and this problem also occurred.Has your problem been solved?

wingkeihon avatar Mar 21 '22 11:03 wingkeihon

@hhxzzy I'm sorry to bother you.I added the contrast loss function to my model and code, and this problem also occurred.Has your problem been solved?

Hello. I try to make some change to the code, but the contrastive loss is still not going to drop much. But it seems that adding the contrastive can help improve the mIOU on Cityscapes by about 1%. Maybe it is the nature of contrastive loss that it doesn't drop much. By the way, do you use warmup_iter in your code. I found that using a warm up strategy can be helpful. The author use this strategy in his code but not metion it in the paper.

hhxzzy avatar Mar 21 '22 15:03 hhxzzy

已收到

wingkeihon avatar Mar 21 '22 15:03 wingkeihon

@hhxzzy @guwen007 @wingkeihon Thanks for your interests. The contrastive loss is indeed more difficult to optimize than the CE loss. But it will still help to learn a better embedding space, which will benefit segmentation. So I will suggest to see whether the final segmentation performance is improved.

tfzhou avatar Mar 21 '22 16:03 tfzhou

@tfzhou @hhxzzy @wingkeihon @guwen007 I am a novice postgraduate, and my coding ability is not high. I want to use ContrastiveSeg method on my own two-class segmentation model. Which py files should I read or what should I pay attention to? Looking forward to your answer, thank you very much.

Pantherk1 avatar Mar 23 '22 15:03 Pantherk1

@tfzhou @hhxzzy @wingkeihon @guwen007 I am a novice postgraduate, and my coding ability is not high. I want to use ContrastiveSeg method on my own two-class segmentation model. Which py files should I read or what should I pay attention to? Looking forward to your answer, thank you very much.

If you want to run the author's scripts directly, you can take configs/cityscapes/H_48_D_4.json as an example. You need to change "data" and "loss“/"params"/"ce_weight" according to your dataset. If you wanna use contrastive loss on your own code instead of running the author's scripts, you should look at lib/loss/loss_contrast.py and lib/loss/loss_contrast_mem.py to read the implement of contrastive loss.

hhxzzy avatar Mar 23 '22 16:03 hhxzzy

@tfzhou @hhxzzy @wingkeihon @guwen007 I am a novice postgraduate, and my coding ability is not high. I want to use ContrastiveSeg method on my own two-class segmentation model. Which py files should I read or what should I pay attention to? Looking forward to your answer, thank you very much.

If you want to run the author's scripts directly, you can take configs/cityscapes/H_48_D_4.json as an example. You need to change "data" and "loss“/"params"/"ce_weight" according to your dataset. If you wanna use contrastive loss on your own code instead of running the author's scripts, you should look at lib/loss/loss_contrast.py and lib/loss/loss_contrast_mem.py to read the implement of contrastive loss.

Thank you for your prompt attention.

Pantherk1 avatar Mar 25 '22 00:03 Pantherk1