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

Fix a regression bug for ExpandedDistribution #972

Merged
merged 3 commits into from
Mar 29, 2021

Conversation

fehiepsi
Copy link
Member

@fehiepsi fehiepsi commented Mar 23, 2021

The bug is reported in forum

import numpyro.distributions as dist
from jax import random
import numpy as np

dist.Poisson(np.array([[1], [10], [100]])).expand([3, 10]).sample(random.PRNGKey(0))

returns

DeviceArray([[  2,  12,  88,   1,  12,  93,   0,  10, 113,   3],
             [  9, 117,   1,  10,  95,   2,   8,  88,   1,  11],
             [ 99,   1,   8,  95,   0,  12, 112,   1,   9, 105]],            dtype=int32)

This regression issue is introduced in #909 where some simplifications are performed and the tests do not cover the change.

@fehiepsi fehiepsi added awaiting review bug Something isn't working labels Mar 23, 2021
@fehiepsi fehiepsi added this to the 0.6.1 milestone Mar 23, 2021
@fehiepsi fehiepsi requested a review from fritzo March 28, 2021 04:04
fritzo
fritzo previously approved these changes Mar 28, 2021
of size 1 in the original batch_shape of base_dist with those
in the expanded dims.
"""
for dim1, dim2 in zip(interstitial_dims, interstitial_sample_dims):
Copy link
Member

Choose a reason for hiding this comment

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

seems reasonable, but this might be cheaper using a single np.transpose rather than a loop of np.swapaxes calls.

@fehiepsi
Copy link
Member Author

Thanks for reviewing and the helpful comment, @fritzo!

@fritzo fritzo merged commit b6acb19 into pyro-ppl:master Mar 29, 2021
@fehiepsi fehiepsi modified the milestones: 0.6.1, 0.7 May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants