-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Use RandomState instead of global random seed in Orthogonal initializer #12232
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
Conversation
I'm not sure I understand. If we follow your reasonning, which packages should use np.random.seed and which packages shouldn't? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR!
Ideally, calling black-box Keras functions shouldn't modify the randomness behavior of downstream calls to Numpy that are unrelated to Keras. So we should avoid changing the global seed if possible. |
de1aa08
to
f44cbc0
Compare
Ok that makes sense. |
f44cbc0
to
df14783
Compare
@fchollet PR is green now. |
If I'm not mistaken, this PR would have the unintended consequence that people using |
Yes, I'm afraid this is true. |
I think we should prioritize this use case over "Keras should not modify the global random state". I think it might be possible to have both, if we use the global random state to generate a local one? |
Interesting idea, let me try that out. |
9a8094b
to
68ced41
Compare
Yeah, the original test passes as before with global random seed. Also added another test to verify initializer with local random seed. |
I have a very similar PR that also removes global seeding from the dataset readers, as well as the orthogonal initializer. Sorry I haven't discovered this PR earlier because I looked for this issue in the tickets rather than PRs. #12259 |
68ced41
to
59b2362
Compare
Closing, reason is -> #12259 (comment) |
Summary
np.random.seed
modifies global seed that other packages or programs where Keras is being imported into have access to. This may lead to confusion and errors.Related Issues
PR Overview
It looks like seeding random globally is not required in Orthogonal initializer.
Using
np.random.RandomState
instead of globalnp.random.seed
to generate normal distribution.