-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
"add init seed" #6221
"add init seed" #6221
Conversation
@@ -302,7 +312,7 @@ class MSRAInitializer(Initializer): | |||
(https://arxiv.org/abs/1502.01852) | |||
""" | |||
|
|||
def __init__(self, uniform=True, fan_in=None, seed=0): | |||
def __init__(self, uniform=True, fan_in=None, seed=set_random_seed(0)): |
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.
Could the user set the seed globally instead of setting the seed at each parameter initializer?
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.
I didn't get an elegant way to implement it. Use a global seed seems ugly,
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.
fixed
@@ -1,7 +1,13 @@ | |||
import framework | |||
import numpy as np | |||
|
|||
__all__ = ['Constant', 'Uniform', 'Normal', 'Xavier'] | |||
__all__ = ['Constant', 'Uniform', 'Normal', 'Xavier', 'set_random_seed'] |
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.
set_random_seed
seems a private function, if it is, do not expose it.
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.
fixed.
@@ -132,6 +132,8 @@ def __call__(self, var, block): | |||
assert isinstance(var, framework.Variable) | |||
assert isinstance(block, framework.Block) | |||
# Initialization Ops should be prepended and not appended | |||
if block.program.random_seed != 0 and self._seed == 0: |
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.
If we don't consider case that user need to overwrite program default rand seed with 0, just use if self._seed == 0
is fine, maybe?
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.
that's true.
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
fix #6220