TFboys-lzz / MPSCL

This repository contains code for the paper "Margin Preserving Self-paced Contrastive Learning Towards Domain Adaptation for Medical Image Segmentation", published at IEEE JBHI 2022
29 stars 1 forks source link

how to train from scratch #8

Closed xiro2 closed 1 year ago

xiro2 commented 1 year ago

dear author, i want to train from scratch for another dataset, how can i train it, first train the warmup.yml for 4000 iterations,second using the trained parameters for training mpscl.yml?

TFboys-lzz commented 1 year ago

Yes,you are right, but don't forger to compute the initial category prototypes based on the pretrained model.

xiro2 commented 1 year ago

Yes,you are right, but don't forger to compute the initial category prototypes based on the pretrained model.

I have used your mr_ct prototype provided by your pretrained_model, in the first iteration, i set the category prototypes coefficient m to zero, then in the following iterations, the coefficient is set according to your yml file, is it ok? The number of classes in my experiments are 5, just like your mmwhs dataset

TFboys-lzz commented 1 year ago

This is not recommended. The distribution of various datasets is different, so a prototype built based on my pre-trained model may not be suitable for your dataset. The best method is to pre-train the model based on your own dataset, which won't take much time.

xiro2 commented 1 year ago

This is not recommended. The distribution of various datasets is different, so a prototype built based on my pre-trained model may not be suitable for your dataset. The best method is to pre-train the model based on your own dataset, which won't take much time.

Even when i set coefficient m=0 in the first epoch? I thought when I set the coefficient CLASS_CENTER_M=0, then it is a initialization procedure.

CLASS_CENTER_M is in line 19 of scripts/configs/MPSCL_MR2CT.yml

我的英语不好,可能表述不准确,用中文说的话,就是我在第一次迭代让CLASS_CENTER_M这个参数为0,在第二次及之后的迭代,CLASS_CENTER_M这个参数才是follow你配置文件里的值

TFboys-lzz commented 1 year ago

不好意思,我不太清楚您这里的第一次迭代是什么意思,是warmup阶段的第一次iteration吗

xiro2 commented 1 year ago

不是的,我的意思是在warmup_mr2ct.yml这个配置下先训练出一个模型,然后在mpscl_mr2ct.yml这个配置下加载warmup_mr2ct.yml训练出的模型。 我改变的地方是:我更改了你train_uda.py这个文件,使得第一次迭代中CLASS_CENTER_M这个值为0,在第二次迭代及之后,CLASS_CENTER_M这个值才和你mpscl_mr2ct.yml中设定的值一样,CLASS_CENTER_M是你train_uda.py这个文件中第125行中的m参数。 不知道这样算不算对原型的初始化?

TFboys-lzz commented 1 year ago

哦哦了解了,这样算是初始化,但是不太建议这样。因为这样的原型是由一个batch的数据初始化的,可能会存在比较多的噪声,不太准确,建议是在源域forward一遍,计算相应的原型。

xiro2 commented 1 year ago

好的,我知道该怎么做了,太感谢你了,很庆幸能遇到你这样的作者,致敬!

TFboys-lzz commented 1 year ago

很高兴能帮助到您!祝好!!!

cqjtuhxf commented 4 months ago

请问您是如何初始化类别原型的