(self, rank, num_workers)
| 10 | |
| 11 | class WorkerInit(object): |
| 12 | def __init__(self, rank, num_workers): |
| 13 | self.rank = rank |
| 14 | self.num_workers = num_workers |
| 15 | def func(self, pid): |
| 16 | print(f'[rank{self.rank}] setting worker seed {self.rank*self.num_workers+pid}', flush=True) |
| 17 | np.random.seed(self.rank*self.num_workers+pid) |