Skip to content

[BUG] genjax.mh and genjax.Map don't play well together #407

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

Closed
midfield opened this issue Jul 6, 2023 · 3 comments · Fixed by #425
Closed

[BUG] genjax.mh and genjax.Map don't play well together #407

midfield opened this issue Jul 6, 2023 · 3 comments · Fixed by #425
Assignees
Labels
bug Something isn't working

Comments

@midfield
Copy link
Collaborator

midfield commented Jul 6, 2023

Describe the bug
See code below

To Reproduce

@genjax.gen
def model():
    loc = genjax.normal(0., 1.) @ 'loc'
    xs = genjax.Map(genjax.normal, in_axes=(None, 0))(loc, jnp.arange(10)) @ 'xs'
    return xs

_, trace = genjax.simulate(model)(key, ())

@genjax.gen
def proposal(choices):
    loc = choices['loc']
    xs = genjax.Map(genjax.normal, in_axes=(None, 0))(loc, jnp.arange(10)) @ 'xs'
    return xs

genjax.mh(proposal).apply(key, trace, ())

Expected behavior
Doesn't produce error.

Execution environment (please complete the following information):

  • OS: Linux
  • Python version: 3.11
  • GenJAX version: 0.0.1
@midfield midfield added the bug Something isn't working label Jul 6, 2023
@femtomc
Copy link
Collaborator

femtomc commented Jul 6, 2023

@midfield I think the correct example is this:

@genjax.gen
def model():
    loc = genjax.normal(0., 1.) @ 'loc'
    xs = genjax.Map(genjax.normal, in_axes=(None, 0))(loc, jnp.arange(10)) @ 'xs'
    return xs

_, trace = genjax.simulate(model)(key, ())

@genjax.gen
def proposal(choices):
    loc = choices['loc']
    xs = genjax.Map(genjax.normal, in_axes=(None, 0))(loc, jnp.arange(10)) @ 'xs'
    return xs

genjax.mh(proposal).apply(key, trace, ())

(Note change to Map invocation in the proposal).

This throws for me:

ValueError: Expected tuple, got [Array(-0.10823099, dtype=float32), Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 
dtype=int32)].

with an error from one of the axis size dimension functions.

@midfield
Copy link
Collaborator Author

midfield commented Jul 6, 2023

Yes, that's right, sorry for the typo. I edited the original report. But this is still an error no?

@femtomc
Copy link
Collaborator

femtomc commented Jul 6, 2023

It is! That's a type issue -- a function expects a tuple somewhere, and we're providing a list -- which is coming from some of the incremental computing tracers, etc.

I'll investigate and fix.

femtomc added a commit that referenced this issue Jul 21, 2023
femtomc added a commit that referenced this issue Jul 21, 2023
sritchie pushed a commit that referenced this issue Jan 8, 2024
sritchie pushed a commit that referenced this issue Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants