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
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
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
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
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
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
def _test(alpha, size): val_est = dirichlet.rvs(alpha, size=size).shape val_true = (size, ) + np.asarray(alpha).shape assert val_est == val_true
def sample(self, size=1): alpha = self.alpha.eval() return dirichlet.rvs(alpha, size=size)
def np_sample(alpha): # get `size` from lexical scoping return dirichlet.rvs(alpha, size=n).astype(np.float32)
def np_sample(alpha): # get ``n`` from lexical scoping return dirichlet.rvs(alpha, size=n).astype(np.float32)