Beispiel #1
0
    def bernoulli(self,
                  name,
                  logits,
                  n_samples=None,
                  group_ndims=0,
                  dtype=tf.int32,
                  **kwargs):
        """
        Add a stochastic node in this :class:`BayesianNet` that follows the
        Bernoulli distribution.

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

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

        :return: A :class:`StochasticTensor` instance.
        """
        dist = distributions.Bernoulli(logits,
                                       group_ndims=group_ndims,
                                       dtype=dtype,
                                       **kwargs)
        return self.stochastic(name, dist, n_samples=n_samples, **kwargs)
Beispiel #2
0
 def __init__(self,
              name,
              logits,
              n_samples=None,
              group_ndims=0,
              dtype=None,
              **kwargs):
     bernoulli = distributions.Bernoulli(logits,
                                         group_ndims=group_ndims,
                                         dtype=dtype,
                                         **kwargs)
     super(Bernoulli, self).__init__(name, bernoulli, n_samples)
Beispiel #3
0
    def __init__(self, logits, dtype=tf.int32):
        """
        Construct the :class:`Bernoulli`.

        Args:
            logits: A `float` tensor, log-odds of probabilities of being 1.
                :math:`\\mathrm{logits} = \\log \\frac{p}{1 - p}`
            dtype: The value type of samples from the distribution.
                (default ``tf.int32``)
        """
        super(Bernoulli, self).__init__(
            zd.Bernoulli(logits=logits, dtype=dtype))