def __init__(self, probs=None, logits=None, name="Categorical", learnable=False, is_observed=False): self._type = "Categorical" if probs is not None and logits is None: ranges = {"p": geometric_ranges.Simplex()} super().__init__(name, probs=probs, learnable=learnable, ranges=ranges, is_observed=is_observed) self.distribution = distributions.CategoricalDistribution() elif logits is not None and probs is None: ranges = {"logits": geometric_ranges.UnboundedRange()} super().__init__(name, logits=logits, learnable=learnable, ranges=ranges, is_observed=is_observed) self.distribution = distributions.CategoricalDistribution() else: raise ValueError("Either probs or " + "logits needs to be provided as input")
def __init__(self, tau, p, name, learnable=False): self._type = "Concrete" ranges = { "tau": geometric_ranges.RightHalfLine(0.), "p": geometric_ranges.Simplex() } super().__init__(name, tau=tau, p=p, learnable=learnable, ranges=ranges) self.distribution = distributions.ConcreteDistribution()
def __init__(self, p=None, softmax_p=None, name="Categorical", learnable=False): self._type = "Categorical" if p is not None and softmax_p is None: ranges = {"p": geometric_ranges.Simplex()} super().__init__(name, p=p, learnable=learnable, ranges=ranges) self.distribution = distributions.CategoricalDistribution() elif softmax_p is not None and p is None: ranges = {"softmax_p": geometric_ranges.UnboundedRange()} super().__init__(name, softmax_p=softmax_p, learnable=learnable, ranges=ranges) self.distribution = distributions.CategoricalDistribution() else: raise ValueError("Either p or " + "softmax_p needs to be provided as input")