dimanche 5 juillet 2020

How to replicate np.random result directly?

import numpy as np
np.seed(1)
a=np.random.randint(10)
b=np.random.randint(10)

I know that after setting the random seed, every time I run this code, a and b will always be initialized to some fixed value, respectively.

My question is: In a new run, how can I directly generate b's value without generating a's value first?

In my mind, I need something like:

import numpy as np
np.seed(1)
a = np.random.randint(10)
# DO SOMETHING to get some situation-specific information, something like a new seed

So that in the new run, I can do like:

# DO SOMETHING to load or set that situation-specific information
b = np.random.randint(10)

Is there any way to do this?




Aucun commentaire:

Enregistrer un commentaire