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

Bug: Dirichlet distribution got invalid concentration parameter for BetaDistribution #1237

Merged
merged 8 commits into from
Nov 29, 2021

Conversation

MarcoGorelli
Copy link
Contributor

@MarcoGorelli MarcoGorelli commented Nov 24, 2021

closes #1206

Couple of changes needed to happen:

  • the mean parameter of BetaProportion should be between 0 and 1 not inclusive of the extremes, otherwise one of the concentration parameters will be 0
  • the initialisation of Beta needs to happen before that of Dirichelet, as suggested in the issue

@MarcoGorelli MarcoGorelli force-pushed the validate-beta-proportion branch 3 times, most recently from 218c589 to b032a45 Compare November 24, 2021 21:46
@MarcoGorelli MarcoGorelli force-pushed the validate-beta-proportion branch from b032a45 to a21a5e5 Compare November 24, 2021 21:49
@MarcoGorelli MarcoGorelli marked this pull request as draft November 25, 2021 10:46
@MarcoGorelli MarcoGorelli marked this pull request as ready for review November 25, 2021 12:07
fehiepsi
fehiepsi previously approved these changes Nov 27, 2021
Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

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

Nice solution! Thanks, @MarcoGorelli!

@@ -1121,6 +1121,19 @@ def _transform_to_interval(constraint):
)


@biject_to.register(constraints.open_interval)
Copy link
Member

Choose a reason for hiding this comment

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

You can add this to the above def _transform_to_interval(constraint):, so no need to reimplement the transform.

@MarcoGorelli MarcoGorelli marked this pull request as ready for review November 27, 2021 13:35
@MarcoGorelli
Copy link
Contributor Author

Thanks @fehiepsi !

I tried chaining the decorators, i.e.

@biject_to.register( constraints.open_interval)
@biject_to.register(constraints.interval)

but that didn't work, so I modified biject_to.register to accept a list of constraints

for constraint in constraint_list:
if isinstance(constraint, constraints.Constraint):
constraint = type(constraint)
self._registry[constraint] = factory
Copy link
Member

Choose a reason for hiding this comment

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

Oops, really sorry, I think we need to return factory here. Could you revert to the previous commit and add

def register(...):
    ...
    return factory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right - that works, thanks!

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

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

Thanks, @MarcoGorelli!

@fehiepsi fehiepsi merged commit e721632 into pyro-ppl:master Nov 29, 2021
@MarcoGorelli MarcoGorelli deleted the validate-beta-proportion branch November 30, 2021 07:42
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

Successfully merging this pull request may close these issues.

Bug: Dirichlet distribution got invalid concentration parameter for BetaDistribution
2 participants