예제 #1
0
    def binomial(self,
                 name,
                 logits,
                 n_experiments,
                 n_samples=None,
                 group_ndims=0,
                 dtype=tf.int32,
                 check_numerics=False,
                 **kwargs):
        """
        Add a stochastic node in this :class:`BayesianNet` that follows the
        Binomial distribution.

        :param name: The name of the stochastic node. Must be unique in a
            :class:`BayesianNet`.

        See
        :class:`~zhusuan.distributions.univariate.Binomial` for more information
        about the other arguments.

        :return: A :class:`StochasticTensor` instance.
        """
        dist = distributions.Binomial(logits,
                                      n_experiments,
                                      group_ndims=group_ndims,
                                      dtype=dtype,
                                      check_numerics=check_numerics,
                                      **kwargs)
        return self.stochastic(name, dist, n_samples=n_samples, **kwargs)
예제 #2
0
 def __init__(self,
              name,
              logits,
              n_experiments,
              n_samples=None,
              group_event_ndims=0,
              dtype=None,
              check_numerics=False):
     binomial = distributions.Binomial(logits,
                                       n_experiments,
                                       group_event_ndims=group_event_ndims,
                                       dtype=dtype,
                                       check_numerics=check_numerics)
     super(Binomial, self).__init__(name, binomial, n_samples)