예제 #1
0
파일: gibbs.py 프로젝트: ylfzr/edward
    def __init__(self, latent_vars, proposal_vars=None, data=None):
        """
    Parameters
    ----------
    proposal_vars : dict of RandomVariable to RandomVariable, optional
      Collection of random variables to perform inference on; each is
      binded to its complete conditionals which Gibbs cycles draws on.
      If not specified, default is to use ``ed.complete_conditional``.

    Examples
    --------
    >>> x_data = np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 1])
    >>>
    >>> p = Beta(1.0, 1.0)
    >>> x = Bernoulli(p=p, sample_shape=10)
    >>>
    >>> qp = Empirical(tf.Variable(tf.zeros(500)))
    >>> inference = ed.Gibbs({p: qp}, data={x: x_data})
    """
        if proposal_vars is None:
            proposal_vars = {
                z: complete_conditional(z)
                for z in six.iterkeys(latent_vars)
            }
        else:
            check_latent_vars(proposal_vars)

        self.proposal_vars = proposal_vars
        super(Gibbs, self).__init__(latent_vars, data)
예제 #2
0
파일: gibbs.py 프로젝트: zhuoliwu/edward
  def __init__(self, latent_vars, proposal_vars=None, data=None):
    """Create an inference algorithm.

    Args:
      proposal_vars: dict of RandomVariable to RandomVariable, optional.
        Collection of random variables to perform inference on; each is
        binded to its complete conditionals which Gibbs cycles draws on.
        If not specified, default is to use `ed.complete_conditional`.
    """
    if proposal_vars is None:
      proposal_vars = {z: complete_conditional(z)
                       for z in six.iterkeys(latent_vars)}
    else:
      check_latent_vars(proposal_vars)

    self.proposal_vars = proposal_vars
    super(Gibbs, self).__init__(latent_vars, data)