https://github.com/GPflow/GPflow
Raw File
Tip revision: 78238bd412bd8eb1422733a254fd1aeefc123ea3 authored by Artem Artemev on 14 November 2019, 15:23:18 UTC
Prepare release 2.0.0-rc1 (#1153)
Tip revision: 78238bd
bijectors.py
from typing import Optional

import tensorflow_probability as tfp

from .. import config
from .utilities import to_default_float

__all__ = ["positive", "triangular"]


def positive(lower: Optional[float] = None):
    lower_value = config.default_positive_minimum()
    if lower_value is None:
        return tfp.bijectors.Softplus()

    shift = to_default_float(lower_value)
    bijectors = [tfp.bijectors.AffineScalar(shift=shift), tfp.bijectors.Softplus()]
    return tfp.bijectors.Chain(bijectors)


triangular = tfp.bijectors.FillTriangular
back to top