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

Implicitly setting a random seed? #1868

Closed
miriaford opened this issue May 17, 2020 · 8 comments
Closed

Implicitly setting a random seed? #1868

miriaford opened this issue May 17, 2020 · 8 comments
Labels
help wanted Open to be worked on question Further information is requested

Comments

@miriaford
Copy link

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

import pytorch_lightning
import random
print(random.randint(0, 100000))

If you run this script repeatedly, you will get the same 'random' integer. PyTorch-lightning seems to be setting a random seed behind the hood. This is very dangerous because I want to show the variance of my algorithm, and PTL actually makes (part of) it deterministic.

Expected behavior

PTL shouldn't set the seed without the user's permission.

@miriaford miriaford added bug Something isn't working help wanted Open to be worked on labels May 17, 2020
@Borda Borda added question Further information is requested and removed bug Something isn't working labels May 17, 2020
@williamFalcon
Copy link
Contributor

pl doesn’t set the seed anywhere. we have a function you can use to do it. search the codebase for the word seed

@williamFalcon
Copy link
Contributor

@miriaford
Copy link
Author

Yes, but why do I get deterministic random int every time I run the script? I didn't set any seed explicitly. It's only 3 lines, you can try it yourself.

@miriaford
Copy link
Author

Also if I simply remove the first line import pytorch_lightning, the script prints a different int every time (which is the expected behavior)

@williamFalcon
Copy link
Contributor

(env) ➜  Desktop python a.py
319
(env) ➜  Desktop python a.py
350
(env) ➜  Desktop python a.py
548
(env) ➜  Desktop cat a.py
import pytorch_lightning
import random
print(random.randint(0, 1000))

@miriaford
Copy link
Author

I don't know why I'm getting the deterministic behavior - I'm on PL 0.7.5, both OS X and Ubuntu 16.04 give me the same issue

@williamFalcon
Copy link
Contributor

williamFalcon commented May 17, 2020

Not sure... we're very aware of correct research practices. Double check your environment or how you're running this...

Here's a discussion showing how hard we thought about adding the seed_everything function... we don't do new feature decisions lightly.

Check this PR
#1572

@miriaford
Copy link
Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Open to be worked on question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants