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

Feature Request: Capability to fix the seed for all keras kernel initializers #31149

Closed
mhaghighat opened this issue Jul 29, 2019 · 3 comments
Closed
Assignees
Labels
comp:keras Keras related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author TF 2.0 Issues relating to TensorFlow 2.0 type:feature Feature requests

Comments

@mhaghighat
Copy link

System information

  • TensorFlow version (you are using): 2.0-beta
  • Are you willing to contribute it (Yes/No): No

Describe the feature and the current behavior/state.
If you create a Keras model, the only way to make your model reproducible is to repeat setting the seed for the kernel_initializer in every layer. This makes the code bulky and more prone to error. For example, a reproducible code looks like this:

np.random.seed(1)
tf.set_random_seed(1)
# FEATURE REQUEST for another parameter like the ones above that we can set
# here and avoid repeating initializer seed in each and every layer below

model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(8, activation='relu', kernel_initializer=keras.initializers.glorot_uniform(seed=1), input_shape=[1]))
model.add(tf.keras.layers.Dense(8, activation='relu', kernel_initializer=keras.initializers.glorot_uniform(seed=1)))
model.add(tf.keras.layers.Dense(1, activation='linear', kernel_initializer=keras.initializers.glorot_uniform(seed=1)))

I wonder if you can add a default seed parameter that we can set and it affects all the initializers.

Will this change the current api? How?
No

Who will benefit with this feature?
Anyone who likes clean code and would like to create reproducible models.

@mhaghighat mhaghighat changed the title Capability to fix the seed for all keras.initializers Feature Request: Capability to fix the seed for all keras.initializers Jul 29, 2019
@mhaghighat mhaghighat changed the title Feature Request: Capability to fix the seed for all keras.initializers Feature Request: Capability to fix the seed for all keras kernel initializers Jul 29, 2019
@gowthamkpr gowthamkpr self-assigned this Jul 29, 2019
@gowthamkpr gowthamkpr added 2.0.0-beta0 type:feature Feature requests comp:keras Keras related issues labels Jul 29, 2019
@gowthamkpr gowthamkpr assigned fchollet and unassigned gowthamkpr Jul 29, 2019
@jvishnuvardhan jvishnuvardhan added TF 2.0 Issues relating to TensorFlow 2.0 and removed TF 2.0.0-beta0 labels Sep 9, 2019
@jvishnuvardhan
Copy link
Contributor

@mhaghighat Sorry for the late response.
Look like you are looking for the following feature.
https://www.tensorflow.org/api_docs/python/tf/config/experimental/enable_op_determinism

If you think the above is not the feature you are looking, please feel free to open a PR in keras-team/keras repo. repository.

Please note that Keras development moved to keras-team/keras repository to focus on only keras. Thanks!

@jvishnuvardhan jvishnuvardhan added the stat:awaiting response Status - Awaiting response from author label Dec 1, 2021
@jvishnuvardhan jvishnuvardhan self-assigned this Dec 1, 2021
@google-ml-butler
Copy link

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.

@google-ml-butler google-ml-butler bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label Dec 8, 2021
@google-ml-butler
Copy link

Closing as stale. Please reopen if you'd like to work on this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author TF 2.0 Issues relating to TensorFlow 2.0 type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

4 participants