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

New window_adaptation syntax #2

Closed
forgi86 opened this issue Sep 17, 2024 · 5 comments
Closed

New window_adaptation syntax #2

forgi86 opened this issue Sep 17, 2024 · 5 comments

Comments

@forgi86
Copy link
Contributor

forgi86 commented Sep 17, 2024

Hello, I an new to blackjax and recently came across your nice examples. However, I had to change a few line of codes to use recent versions of the jax/blackjax ecosystem, in particular the adaptation algorithm. For instance, in bayesian-neural-network.ipynb, I had to change the lines below the definition of the "potential" to:

warmup = blackjax.window_adaptation(blackjax.nuts, potential)
(state, parameters), _ = warmup.run(key_warmup, params)

kernel = blackjax.nuts(potential, **parameters).step
states = inference_loop(key_samples, kernel, state, num_steps)
sampled_params = states.position
@gerdm
Copy link
Owner

gerdm commented Sep 17, 2024

Hi @forgi86,

Could you please make a PR request with these new changes?

Thanks!

@forgi86
Copy link
Contributor Author

forgi86 commented Sep 17, 2024

Hello @gerdm,

I opened a PR, but only fixed the bayesian-neural-network example. I was trying to fix the bnn-hierarchical-flax example (that is the most interesting for my current activities), but there seems to be another bug there.

I can't evaluate the potential, if I run

potential(params_all)

it throws a ValueError: Arity mismatch between trees

Unfortunately I don't have time to look into it at the moment...

@forgi86
Copy link
Contributor Author

forgi86 commented Sep 19, 2024

OK, I also fixed the bug in the hbnn potential. Variable params_sigma_tree in build_sigma_tree had one more singletone initial dimension than needed (perhaps a change in linen's pytree structure?)

All fixed in my fork (https://github.com/forgi86/bayes). I also made a few changes to remove warnings for deprecated stuff.

@gerdm
Copy link
Owner

gerdm commented Sep 19, 2024

Thanks for your contribution @forgi86!

I'll take a look at this tonight.

@gerdm
Copy link
Owner

gerdm commented Oct 2, 2024

Closed by #3

@gerdm gerdm closed this as completed Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants