def sample_v_given_h(self, h, eps=1e-5):
mean_v = self.mean_v.eval(feed_dict={self.hidden: h})
if not self.beta_sampling:
rnds = np.random.randn(mean_v.shape[0], mean_v.shape[1]).astype(h.dtype)
return np.clip(mean_v + rnds * self.sigma, eps, 1. - eps)
mvvm = mean_v * (1 - mean_v)
var_v = np.fmin(mvvm, self.sigma**2)
operand = (mvvm + 1.5 * eps) / (var_v + eps) - 1
alpha = mean_v * operand + eps
beta = (1 - mean_v) * operand + eps
return np.random.beta(alpha, beta).astype(h.dtype)
评论列表
文章目录