I am using rng = np.random.default_rng(seed=None) for testing purposes following documentation.
My program is a scientific code, so it is good to have some random values to test it, but if I found a problem with the code's result, I would like to get the seed back and try again to find the problem. Is there any way to do that?
Things like this question does not seem to work with a Generator:
AttributeError: 'numpy.random._generator.Generator' object has no attribute 'get_state'
Of course I can always try a set of predefined seeds, but that is not what I want.
I don't remember if there is a method to get the seed directly. But alternatively you can generate a random number first, print it in logs and then set that number as seed for the rest of the program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With