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

Improve rng default in the contrib/model.py module #1992

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

juanitorduz
Copy link
Contributor

Closes #1991

@fehiepsi
Copy link
Member

fehiepsi commented Mar 1, 2025

I think it is the issue of contrib.module. We can use

rng_key = numpyro.prng_key() or random.key(0)

to optionally create dummy rng_key. I think it does not affect the functionality of the module.

@juanitorduz
Copy link
Contributor Author

I think it is the issue of contrib.module. We can use

rng_key = numpyro.prng_key() or random.key(0)

to optionally create dummy rng_key. I think it does not affect the functionality of the module.

Do you mean like 5e40979 ? or something has to be changed in contrib/module.py?

@fehiepsi
Copy link
Member

fehiepsi commented Mar 1, 2025

I think changing in contrib is better because we know that key(0) does not change the logic there. If we change it here, users might forget to provide some posterior samples.

Comment on lines +88 to +89
if rng_key is None:
rng_key = random.key(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do it this way since rng_key = numpyro.prng_key() or random.key(0) we giving an error

E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@juanitorduz juanitorduz changed the title Pass rng to log_likelihood util function Improve rng default in the contrib/model.py module Mar 3, 2025
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

Successfully merging this pull request may close these issues.

log_likelihood fails with random_flax_module (and flax_module)
2 participants