pytorch-cutpaste icon indicating copy to clipboard operation
pytorch-cutpaste copied to clipboard

每次训练的模型,得到的结果差别很大

Open tommying opened this issue 3 years ago • 3 comments

您好! 我想问一下,每次训练得到的模型,得到的结果,差别都很大。(是不是因为 每次都是随机在一张图里cut,paste,导致的?),

比如 bottle这个类,我用相同的参数分别训练两次,得到两个模型model1和model2。 测试的时候,model1 得到的结果是AUC1 = 99.444, model2得到的结果是AUC2 = 99.841. 虽然有误差,但是这相差的也太多了。。。。。 有什么办法可以改善吗?

谢谢

tommying avatar Nov 22 '21 12:11 tommying

Hi,

Maybe follow the pytorch guide on (reproducibility)[https://pytorch.org/docs/stable/notes/randomness.html].

You should set a seed for pytorch and the random library and set the --workers 0 argument. Also disable the nondeterministic cuda algorithms (see the linked guide).

I think this would improve reproducibility.

Runinho avatar Nov 27 '21 16:11 Runinho

@Runinho ok, thinks

tommying avatar Dec 02 '21 08:12 tommying

您好! 我想问一下,每次训练得到的模型,得到的结果,差别都很大。(是不是因为 每次都是随机在一张图里cut,paste,导致的?),

比如 bottle这个类,我用相同的参数分别训练两次,得到两个模型model1和model2。 测试的时候,model1 得到的结果是AUC1 = 99.444, model2得到的结果是AUC2 = 99.841. 虽然有误差,但是这相差的也太多了。。。。。 有什么办法可以改善吗?

谢谢

铁汁,应该是初始化的问题。按照上面老哥的说法,设定一个固定种子一般就可以避免。 歪果仁能看到你的冲文已经很不错咯~

RuojiWang avatar May 09 '22 03:05 RuojiWang