I was wondering if there were a recommended way of using the parallel map feature in pathos.multiprocessing.ProcessPool
for functions that involve random number generation, i.e.,
def f(x):
return x*np.random.rand()
pool = pathos.multiprocessing.ProcessPool(nodes=4)
results = pool.map(f,np.linspace(0,1,11))
I suspect I could do something simple like add np.random.seed()
to the f
function, but I would, ideally, like some reproducibility. Is there a way to just assign a different, known, seed to each of the workers in the pool and then execute the mapping?
Aucun commentaire:
Enregistrer un commentaire