-
-
Notifications
You must be signed in to change notification settings - Fork 986
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
Expose initialization strategy in HMC #2417
Conversation
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.
Re: usability, you could use the standard poutine trick:
def init_to_uniform(site=None, radius=2):
if site is None:
return functools.partial(init_to_uniform, radius=2)
...
Then users can pass init_to_uniform(radius=0.5)
as their function.
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.
This is great!
Do I understand correctly that this allows me to specify a subset of init_params
to do so in the constrained space (unlike the initial_params
kwarg, which if so we should mark DEPRECATED).
@fritzo
Thanks, yeah we should do it! |
Yes, you just need to specify a subset. The remaining params use the |
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 implementing this!
@fritzo - does this address your concern of initialization code being triggered at various points in the flow despite the user specifying initial params? |
@neerajprad This does not. I think we should address it. |
I am fixing some typos. I'll address that too. |
Thanks for clarifying, @fehiepsi. That might involve some refactoring, look forward to seeing your PR. Let me know if I can help. |
Yes this addresses my concern with duplicated work. The problem was, the model was running 100 random initializations even if I provided a single good one. After This PR, if I provide a single good initialization through |
Addresses part of #2415.
There is one issue is: if users want to change keywords of init strategies, they have to use
partial
, e.g.partial(init_to_median, num_samples=20)
. I find that it is a bit inconvenient for users. In NumPyro, users can setinit_strategy=
init_to_median(20)
orinit_to_uniform(3)
,init_to_value({"x": 10})
,init_to_feasible()
.