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

Add transforms' forward_shape and inverse_shape #887

Merged
merged 6 commits into from
Jan 24, 2021

Conversation

fehiepsi
Copy link
Member

This PR steals @fritzo implementation in pytorch/pytorch#50581 and resolve various issues that couldn't be addressed previously. Thanks for your effort, @fritzo!

fritzo
fritzo previously approved these changes Jan 22, 2021
Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

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

Thanks for porting this! My only suggestion is to add a comment about .forward_shape() versus .forward_event_shape().

numpyro/contrib/tfp/distributions.py Outdated Show resolved Hide resolved
numpyro/distributions/distribution.py Show resolved Hide resolved
numpyro/distributions/distribution.py Outdated Show resolved Hide resolved
@fehiepsi fehiepsi mentioned this pull request Jan 23, 2021
3 tasks
Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

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

Thanks for porting this!

Comment on lines +89 to +93
def forward_shape(self, shape):
out_shape = self.bijector.forward_event_shape(shape)
in_event_shape = self.bijector.inverse_event_shape(out_shape)
batch_shape = shape[:len(shape) - len(in_event_shape)]
return batch_shape + out_shape
Copy link
Member

Choose a reason for hiding this comment

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

Nice trick!

@fritzo fritzo merged commit 90b74eb into pyro-ppl:master Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants