Example #1
0
    def __init__(self, concentration):

        # Check input
        ensure_tensor_like(concentration, "concentration")

        # Store args
        self.concentration = concentration
Example #2
0
    def __init__(self, distributions, logits=None, probs=None):

        # Check input
        if logits is None and probs is None:
            raise ValueError("must pass either logits or probs")
        if probs is not None:
            ensure_tensor_like(probs, "probs")
        if logits is not None:
            ensure_tensor_like(logits, "logits")

        # Distributions should be a pf, tf, or pt distribution
        if not isinstance(distributions, BaseDistribution):
            if get_backend() == "pytorch":
                import torch.distributions as tod

                if not isinstance(distributions, tod.Distribution):
                    raise TypeError(
                        "requires either a ProbFlow or PyTorch distribution")
            else:
                from tensorflow_probability import distributions as tfd

                if not isinstance(distributions, tfd.Distribution):
                    raise TypeError(
                        "requires either a ProbFlow or TensorFlow distribution"
                    )

        # Store args
        self.distributions = distributions
        self.logits = logits
        self.probs = probs
Example #3
0
    def __init__(self, rate):

        # Check input
        ensure_tensor_like(rate, "rate")

        # Store args
        self.rate = rate
Example #4
0
    def __init__(self, concentration, scale):

        # Check input
        ensure_tensor_like(concentration, "concentration")
        ensure_tensor_like(scale, "scale")

        # Store args
        self.concentration = concentration
        self.scale = scale
Example #5
0
    def __init__(self, loc, cov):

        # Check input
        ensure_tensor_like(loc, "loc")
        ensure_tensor_like(cov, "cov")

        # Store args
        self.loc = loc
        self.cov = cov
Example #6
0
    def __init__(self, loc=0, scale=1):

        # Check input
        ensure_tensor_like(loc, "loc")
        ensure_tensor_like(scale, "scale")

        # Store args
        self.loc = loc
        self.scale = scale
Example #7
0
    def __init__(self, concentration, rate):

        # Check input
        ensure_tensor_like(concentration, "concentration")
        ensure_tensor_like(rate, "rate")

        # Store args
        self.concentration = concentration
        self.rate = rate
Example #8
0
    def __init__(self, logits=None, probs=None):

        # Check input
        if logits is None and probs is None:
            raise TypeError("either logits or probs must be specified")
        if logits is None:
            ensure_tensor_like(probs, "probs")
        if probs is None:
            ensure_tensor_like(logits, "logits")

        # Store args
        self.logits = logits
        self.probs = probs
Example #9
0
    def __init__(self, distributions, logits=None, probs=None):

        # Check input
        # TODO: distributions should be a pf, tf, or pt distribution
        if logits is None and probs is None:
            raise ValueError("must pass either logits or probs")
        if probs is not None:
            ensure_tensor_like(probs, "probs")
        if logits is not None:
            ensure_tensor_like(logits, "logits")

        # Store args
        self.distributions = distributions
        self.logits = logits
        self.probs = probs
Example #10
0
    def __init__(self, initial, transition, observation, steps):

        # Check input
        ensure_tensor_like(initial, "initial")
        ensure_tensor_like(transition, "transition")
        # observation should be a pf, tf, or pt distribution
        if not isinstance(steps, int):
            raise TypeError("steps must be an int")
        if steps < 1:
            raise ValueError("steps must be >0")

        # Store observation distribution
        if isinstance(observation, BaseDistribution):
            self.observation = observation()  # store backend distribution
        else:
            self.observation = observation

        # Store other args
        self.initial = initial
        self.transition = transition
        self.steps = steps