-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Frequently asked questions and answers
Wenqi Li edited this page May 25, 2020
·
16 revisions
A list of frequently asked questions and answers maintained by the core developer team, based on the users' feedback and discussions.
Q1. The randomised data transformations generate insufficiently shuffled outputs. How can I resolve this issue?
This is likely because the random number generator in MONAI is duplicated when multiple workers are initialised by torch.utils.data.Dataloader
(see also Pytorch FAQ, #398).
A possible solution is to set up random seeds in workers via the worker_init_fn
option:
def worker_init_fn(worker_id):
worker_info = torch.utils.data.get_worker_info()
worker_info.dataset.transform.set_random_state(worker_info.seed % (2 ** 32))
dataloader = torch.utils.data.DataLoader(..., worker_init_fn=worker_init_fn)