Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remark : Reproducibility is broken. #7

Open
Tikquuss opened this issue Dec 25, 2020 · 1 comment
Open

Remark : Reproducibility is broken. #7

Tikquuss opened this issue Dec 25, 2020 · 1 comment

Comments

@Tikquuss
Copy link

In notebooks you say: "To ensure we get reproducible results we set the random seed for Python, Numpy and PyTorch.".
But if you do it in a cell of a notebook, it is only valid for that cell, and therefore reproducibility is not guaranteed.
Take a look at this capture.
bad_random_seed

@bentrevett
Copy link
Owner

@Tikquuss Sorry for the late reply. Just getting back from my Christmas break.

Isn't this the expected result? The way I thought it worked is that once you set a random seed then all calls to random.random() (or a similar function) will still give different results, but if I set the seed again and then called random.random() I'll get the same results as when I first called them.

>>> import random
>>> random.seed(1)
>>> random.random() # these three calls should give different "random" results
0.13436424411240122
>>> random.random()
0.8474337369372327
>>> random.random()
0.763774618976614
>>> random.seed(1) # re-seed here so the next three calls give the same "random" results as above
>>> random.random() # which they do
0.13436424411240122
>>> random.random()
0.8474337369372327
>>> random.random()
0.763774618976614

I might not understand how randomness works in Python, please let me know where my mistake is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants