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

[FR] initialize MCMC from a given state #1763

Closed
ssnl opened this issue Feb 18, 2019 · 3 comments
Closed

[FR] initialize MCMC from a given state #1763

ssnl opened this issue Feb 18, 2019 · 3 comments

Comments

@ssnl
Copy link
Contributor

ssnl commented Feb 18, 2019

Issue Description

Sometimes we have domain knowledge about a good initial state, e.g., when the code is run in an online fashion and we want to incorporate new observations into existing inference. In such cases, it would be useful to have a way to initialize MCMC with a given state, or distribution of state values (e.g., maybe represented by a model itself).

@fehiepsi
Copy link
Member

Hi @ssnl , right now you can change initial_trace of an MCMC kernel as follows:

initial_trace = pyro.poutine.trace(model).get_trace(*args, **kwargs)  # args, kwargs are arguments of your model
initial_trace.nodes["a"]["value"] = initial_a
nuts_kernel.initial_trace = initial_trace  # this changes the initial_trace of a kernel

As a side note, right now we don't have a public interface to set initial_traces for different chains. I'll think about how to support it if it is useful for you.

@ssnl
Copy link
Contributor Author

ssnl commented Feb 19, 2019

@fehiepsi Thanks! This code snippet is helpful!

@fritzo fritzo added this to the 0.4 release milestone May 6, 2019
@fehiepsi
Copy link
Member

fehiepsi commented Jul 4, 2019

Now, MCMC class has an initial_params arg which allows users set initial params for different chains (instead of traces).

@fehiepsi fehiepsi closed this as completed Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants