results.samples is an empty dictionary? #111
-
Hi all. I would like to compare i.i.d samples drawn from the hybrid Rosenbrock density with the samples that jaxns outputs as a sanity check. I adapted the double moon likelihood example given in the documentation for my needs, but the run completes with no errors, and Any suggestions on where the mistake may be? Any help would be appreciated. Also, as a follow up, where would be the appropriate location to jax.jit this run? Thank you so much.
For reproducibility, I am using the following code for my model:
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Should be def prior_model():
x = yield Prior(tfpd.Uniform(low=model.lower_bound, high=model.upper_bound), name='x')
return x
Let me know if that works. |
Beta Was this translation helpful? Give feedback.
-
Also, regarding your question about how to compile the runs, here's how: For just-in-time: import jax
ns = DefaultNestedSampler(model=model, max_samples=1e5)
ns_jit = jax.jit(ns)
termination_reason, state = ns_jit(random.PRNGKey(42))
results = ns.to_results(termination_reason=termination_reason, state=state) For ahead-of-time: ns = DefaultNestedSampler(model=model, max_samples=1e5)
ns_compiled = jax.jit(ns).lower(jax.random.PRNGKey(0)).compile()
termination_reason, state = ns_compiled(random.PRNGKey(42))
results = ns.to_results(termination_reason=termination_reason, state=state) If you're going to use it over and over again, I suggest ahead-of-time compiling. Note |
Beta Was this translation helpful? Give feedback.
-
Ah, that was a subtle mistake on my part, thank you for catching that! A follow up question on the jit compilation. The jax documentation suggests using
How would you suggest working around this issue? |
Beta Was this translation helpful? Give feedback.
-
Also a final question. I get agreement with jaxns and the i.i.d sampling on the bounded domain for hybrid rosenbrock! My code looks like
However, my ESS remains about 1900, so the plot doesn't look very nice. What settings would you suggest changing to get an ESS of about 10-20k? Thanks! |
Beta Was this translation helpful? Give feedback.
-
@leviyevalex would you be interested in making a self-contained example script from this model? It looks like a nice example. To do so, just make a jupyter notebook that is self-contained, i.e. the likelihood and prior are fully defined in the script without needing to import an external library. You can either post it as a gist here, or if you're feel up for it, could make a PR and stick in the |
Beta Was this translation helpful? Give feedback.
Should be
name
is an argument forPrior
. Only named priors will be in the resulting samples dict. Howeverresult.U_samples
contains all the information to reconstruct any of them.Let me know if that works.