openspeech icon indicating copy to clipboard operation
openspeech copied to clipboard

How does shuffle works in sampler

Open yinruiqing opened this issue 4 years ago • 3 comments

❓ Questions & Help

I think shuffle method cannot be called by pytorch lightning. That may also cause some problems with 'ddp' mode.

yinruiqing avatar Sep 03 '21 13:09 yinruiqing

Can you explain in more detail why?

sooftware avatar Sep 03 '21 14:09 sooftware

You can find how pl set distributed sampler here. If you dive into the source code of DistributedSampler in pytorch, you can find the random seed depends on the epoch. Pytorch recommends to call set_epoch() at start of each epoch. But I don't know how to do it in pl. If you want shuffle() work, you should also call it explictly at the start of each epoch. In addition, you should also set replace_sampler_ddp=True in trainer

yinruiqing avatar Sep 03 '21 15:09 yinruiqing

I'll check. thanks.

sooftware avatar Sep 08 '21 07:09 sooftware