Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add init strategy to generate sample for ImproperUniform in NumPyro #1713

Merged
merged 5 commits into from
Jun 8, 2021

Conversation

fehiepsi
Copy link
Member

@fehiepsi fehiepsi commented Jun 1, 2021

Description

Resolves #1704. Currently, we run the model to inspect observed variables. However, numpyro does not allow to sample from ImproperUniform distribution. As a workaround, I add an init_strategy method to draw a sample from transform_to_support(Uniform(-2, 2)).

Checklist

  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

@fehiepsi fehiepsi requested a review from OriolAbril June 1, 2021 05:42
@codecov
Copy link

codecov bot commented Jun 1, 2021

Codecov Report

Merging #1713 (9ccc249) into main (4d9caca) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1713   +/-   ##
=======================================
  Coverage   90.86%   90.86%           
=======================================
  Files         108      108           
  Lines       11821    11821           
=======================================
  Hits        10741    10741           
  Misses       1080     1080           
Impacted Files Coverage Δ
arviz/data/io_numpyro.py 93.89% <100.00%> (ø)
arviz/stats/stats.py 96.60% <0.00%> (ø)
arviz/plots/hdiplot.py 92.45% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d9caca...9ccc249. Read the comment docs.

@@ -124,7 +124,10 @@ def arbitrary_element(dct):

observations = {}
if self.model is not None:
seeded_model = numpyro.handlers.seed(self.model, jax.random.PRNGKey(0))
seeded_model = numpyro.handlers.substitute(
numpyro.handlers.seed(self.model, jax.random.PRNGKey(0)),
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining why this is here for whoever reads it next?

@OriolAbril OriolAbril merged commit 33ec4e1 into arviz-devs:main Jun 8, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NumPyroConverter makes too many assumptions about the model
3 participants