jeudi 22 octobre 2020

Set numpy.random.seed on a global scale

How can I set numpy.random.seed(0) on a global scale? It seems I have to reset the seed every time I call a np.random function.

import numpy as np

np.random.seed(0)
print(np.random.randint(0,10,2))
np.random.seed(0)
print(np.random.randint(0,10,2))
print(np.random.randint(0,10,2))

np.random.seed(0)
print(np.random.rand())
np.random.seed(0)
print(np.random.rand())
print(np.random.rand())


[5 0]
[5 0]
[3 3]
0.5488135039273248
0.5488135039273248
0.7151893663724195



Aucun commentaire:

Enregistrer un commentaire