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

Allow gpflow.utilities.triangular() to return FillScaleTriL #1605

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions gpflow/utilities/bijectors.py
Expand Up @@ -43,8 +43,15 @@ def positive(lower: Optional[float] = None, base: Optional[str] = None) -> tfp.b
return bijector


def triangular() -> tfp.bijectors.Bijector:
def triangular(positive_diag: bool = False, diag_bijector=None) -> tfp.bijectors.Bijector:
"""
Returns instance of a triangular bijector.

:param positive_diag: if True, constrains the diagonal to be positive
:param diag_bijector: passed through to FillScaleTriL for positive_diag
"""
return tfp.bijectors.FillTriangular()
if positive_diag:
Copy link
Contributor

Choose a reason for hiding this comment

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

can we not specify a default diag_bijector when positive_diag is set to True?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, None is using the TFP default (Softplus + Shift(1e-5)), see https://www.tensorflow.org/probability/api_docs/python/tfp/bijectors/FillScaleTriL

return tfp.bijectors.FillScaleTriL(diag_bijector=diag_bijector)
else:
assert diag_bijector is None, "should not pass diag_bijector when positive_diag is False"
return tfp.bijectors.FillTriangular()