Example #1
0
 def __init__(self,
              n,
              p=None,
              logit_p=None,
              name="Binomial",
              learnable=False):
     self._type = "Binomial"
     if p is not None and logit_p is None:
         ranges = {
             "n": geometric_ranges.UnboundedRange(),
             "p": geometric_ranges.Interval(0., 1.)
         }
         super().__init__(name,
                          n=n,
                          p=p,
                          learnable=learnable,
                          ranges=ranges)
         self.distribution = distributions.BinomialDistribution()
     elif logit_p is not None and p is None:
         ranges = {
             "n": geometric_ranges.UnboundedRange(),
             "logit_p": geometric_ranges.UnboundedRange()
         }
         super().__init__(name,
                          n=n,
                          logit_p=logit_p,
                          learnable=learnable,
                          ranges=ranges)
         self.distribution = distributions.BinomialDistribution()
     else:
         raise ValueError("Either p or " +
                          "logit_p needs to be provided as input")
Example #2
0
 def __init__(self,
              total_count,
              probs=None,
              logits=None,
              name="Binomial",
              learnable=False,
              is_observed=False):
     self._type = "Binomial"
     if probs is not None and logits is None:
         ranges = {
             "total_count": geometric_ranges.UnboundedRange(),
             "probs": geometric_ranges.Interval(0., 1.)
         }
         super().__init__(name,
                          total_count=total_count,
                          probs=probs,
                          learnable=learnable,
                          ranges=ranges,
                          is_observed=is_observed)
         self.distribution = distributions.BinomialDistribution()
     elif logits is not None and probs is None:
         ranges = {
             "total_count": geometric_ranges.UnboundedRange(),
             "logits": geometric_ranges.UnboundedRange()
         }
         super().__init__(name,
                          total_count=total_count,
                          logits=logits,
                          learnable=learnable,
                          ranges=ranges)
         self.distribution = distributions.BinomialDistribution()
     else:
         raise ValueError("Either probs or " +
                          "logits needs to be provided as input")
Example #3
0
 def __init__(self, total_count, probs=None, logits=None, name="Binomial", learnable=False,
              has_bias=False, is_observed=False, is_policy=False, is_reward=False):
     self._type = "Binomial"
     if probs is not None and logits is None:
         ranges = {"total_count": geometric_ranges.UnboundedRange(), #TODO: It should become natural number in the future
                   "probs": geometric_ranges.Interval(0., 1.)}
         super().__init__(name, total_count=total_count, probs=probs, learnable=learnable,
                          has_bias=has_bias, ranges=ranges, is_observed=is_observed, is_policy=is_policy, is_reward=is_reward)
         self.distribution = distributions.BinomialDistribution()
     elif logits is not None and probs is None:
         ranges = {"total_count": geometric_ranges.UnboundedRange(),
                   "logits": geometric_ranges.UnboundedRange()}
         super().__init__(name, total_count=total_count, logits=logits, learnable=learnable,
                          has_bias=has_bias, ranges=ranges, is_policy=is_policy, is_reward=is_reward)
         self.distribution = distributions.BinomialDistribution()
     else:
         raise ValueError("Either probs or " +
                          "logits needs to be provided as input")