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

vmap produces wrong results silently #239

Open
JTaets opened this issue Jun 22, 2023 · 2 comments
Open

vmap produces wrong results silently #239

JTaets opened this issue Jun 22, 2023 · 2 comments

Comments

@JTaets
Copy link

JTaets commented Jun 22, 2023

rng = jax.random.PRNGKey(0)
loc = jax.random.uniform(rng,(4,1))
logscale = jnp.array([1.])

pi1 = distrax.MultivariateNormalDiag(loc, jnp.exp(logscale))
def apply_dist(x,logscale):
    return distrax.MultivariateNormalDiag(x, jnp.exp(logscale))
pi2 = jax.vmap(apply_dist, (0,None))(loc, jnp.exp(logscale))

print(pi1.sample(seed=rng).shape)  #(4,1)
print(pi2.sample(seed=rng).shape)  #(4,4)
@JTaets
Copy link
Author

JTaets commented Jun 22, 2023

I suppose that the sample inside the vmap function fixes this

@JTaets JTaets closed this as completed Jun 22, 2023
@JTaets
Copy link
Author

JTaets commented Jun 22, 2023

But when requiring the entropy of the full distribution, the results are wrong

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

1 participant