Example #1
0
    def sample(self, size, sess):
        """z ~ q(z | lambda)"""
        alpha = sess.run([self.alpha])
        z = np.zeros((size[1], size[0], self.K))
        for d in xrange(self.num_vars):
            z[d, :, :] = dirichlet.rvs(alpha[d, :], size = size[0])

        return z
Example #2
0
    def sample(self, size, sess):
        """z ~ q(z | lambda)"""
        alpha = sess.run(self.alpha)
        z = np.zeros(size)
        for pi in xrange(self.num_pis):
            z[:, (pi*self.K):((pi+1)*self.K)] = dirichlet.rvs(alpha[pi, :], size=size[0])

        return z
Example #3
0
    def sample(self, size=1):
        """z ~ q(z | lambda)"""
        alpha = self.alpha.eval()
        z = np.zeros((size, self.num_vars))
        for i in range(self.num_factors):
            z[:, (i * self.K):((i + 1) * self.K)] = dirichlet.rvs(alpha[i, :],
                                                                  size=size)

        return z
Example #4
0
    def sample(self, size=1, sess=None):
        """z ~ q(z | lambda)"""
        alpha = sess.run(self.alpha)
        z = np.zeros((size, self.num_vars))
        for i in range(self.num_factors):
            z[:, (i*self.K):((i+1)*self.K)] = dirichlet.rvs(alpha[i, :],
                                                            size=size)

        return z
Example #5
0
    def sample(self, size=1):
        """x ~ p(x | params)"""
        alpha = self.alpha.eval()
        x = np.zeros((size, self.num_vars))
        for i in range(self.num_factors):
            x[:, (i*self.K):((i+1)*self.K)] = dirichlet.rvs(alpha[i, :],
                                                            size=size)

        return x
Example #6
0
    def sample(self, size, sess):
        """z ~ q(z | lambda)"""
        alpha = sess.run(self.alpha)
        z = np.zeros(size)
        for pi in xrange(self.num_pis):
            z[:,
              (pi * self.K):((pi + 1) * self.K)] = dirichlet.rvs(alpha[pi, :],
                                                                 size=size[0])

        return z
Example #7
0
def _test(alpha, size):
    val_est = dirichlet.rvs(alpha, size=size).shape
    val_true = (size, ) + np.asarray(alpha).shape
    assert val_est == val_true
Example #8
0
 def sample(self, size=1):
     alpha = self.alpha.eval()
     return dirichlet.rvs(alpha, size=size)
Example #9
0
 def np_sample(alpha):
     # get `size` from lexical scoping
     return dirichlet.rvs(alpha, size=n).astype(np.float32)
Example #10
0
 def np_sample(alpha):
     # get ``n`` from lexical scoping
     return dirichlet.rvs(alpha, size=n).astype(np.float32)
Example #11
0
def _test(alpha, size):
    val_est = dirichlet.rvs(alpha, size=size).shape
    val_true = (size, ) + np.asarray(alpha).shape
    assert val_est == val_true