jeudi 26 juillet 2018

how to know the seed for a random dataset in python

I have a simple random test code in python-3, where I generate a few random numbers, and do some processing with them, something like this:

random.seed(9001)
while True:
    x = numpy.random.rand((10, 10))
    do_some_processing(x)

My problem is that when I fix the seed, ie it becomes a deterministic run, then the code works fine. But when I delete the seed line, then sometimes the code reports errors. So I need to know for what seed value were the random numbers generated which created the failures.

So, how can I know and print the seed value, so that I can replicate the failure test?




Aucun commentaire:

Enregistrer un commentaire