-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Adding local Random state to fit_loop #12357
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
Adding local Random state to fit_loop #12357
Conversation
@farizrahman4u Do you think this is good? |
This is a good idea, thanks for making the PR! |
@fchollet Think you can take a look? |
@fchollet Can you take a look? |
@@ -32,7 +32,8 @@ def fit_loop(model, fit_function, fit_inputs, | |||
initial_epoch=0, | |||
steps_per_epoch=None, | |||
validation_steps=None, | |||
validation_freq=1): | |||
validation_freq=1, | |||
seed=113): |
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.
We should not use default seeds. This would dramatically reduce randomness (effectively remove randomness since there is no user-facing way to set the seed).
@@ -180,7 +183,7 @@ def fit_loop(model, fit_function, fit_inputs, | |||
if shuffle == 'batch': | |||
index_array = batch_shuffle(index_array, batch_size) | |||
elif shuffle: | |||
np.random.shuffle(index_array) | |||
rng.shuffle(index_array) |
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.
The previous version already does not modify the global behavior of np.random
. The purpose of this PR is not clear to me.
Instead of using a default value, we could use system time instead. Wouldn't that vary the seed more? |
Looked at the PR one more time. |
Summary
We want to avoid using the global numpy random generator as much as possible because it could potentially modify the behavior of other methods calling it as well.
Related Issues
#12258
#12259
PR Overview