Esempio n. 1
0
 def model():
   loc = ed.Normal(loc=0., scale=1., name="loc")
   flip = ed.Bernoulli(probs=0.5, name="flip")
   if tf.equal(flip, 1):
     x = ed.Normal(loc=loc, scale=0.5, sample_shape=5, name="x")
   else:
     x = ed.Poisson(rate=tf.nn.softplus(loc), sample_shape=3, name="x")
   return x
Esempio n. 2
0
def deep_exponential_family(data_size, feature_size, units, shape):
    """A multi-layered topic model over a documents-by-terms matrix."""
    w2 = ed.Gamma(0.1, 0.3, sample_shape=[units[2], units[1]], name="w2")
    w1 = ed.Gamma(0.1, 0.3, sample_shape=[units[1], units[0]], name="w1")
    w0 = ed.Gamma(0.1, 0.3, sample_shape=[units[0], feature_size], name="w0")

    z2 = ed.Gamma(0.1, 0.1, sample_shape=[data_size, units[2]], name="z2")
    z1 = ed.Gamma(shape, shape / tf.matmul(z2, w2), name="z1")
    z0 = ed.Gamma(shape, shape / tf.matmul(z1, w1), name="z0")
    x = ed.Poisson(tf.matmul(z0, w0), name="x")
    return x
def Zheng07SatsPoisson(halo_mvir,
                n_cen,
                logM0=ed.Deterministic(11.2, name='logM0'),
                logM1=ed.Deterministic(12.4, name='logM1'),
                alpha=ed.Deterministic(0.83, name='alpha'),
                name='zheng07Sats', **kwargs):
  M0 = 10.**logM0
  M1 = 10.**logM1
  rate = n_cen.distribution.probs * ((halo_mvir - M0)/M1)**alpha
  rate = tf.where(halo_mvir < M0, 1e-4, rate)
  return ed.Poisson(rate=rate, name=name)
Esempio n. 4
0
def deep_exponential_family(data_size, feature_size, units, shape):
    # units表示每层维数的大小,从unit[2]开始到unit[0],最后输出feature_size
    # data_size为batch_size的意思
    w2 = ed.Gamma(0.1, 0.3, sample_shape=[units[2], units[1]],
                  name="w2")  # 前两个位置为参数
    w1 = ed.Gamma(0.1, 0.3, sample_shape=[units[1], units[0]], name="w1")
    w0 = ed.Gamma(0.1, 0.3, sample_shape=[units[0], feature_size], name="w0")
    # z2相当于是原始分布,用z2结合参数传到生成x
    z2 = ed.Gamma(0.1, 0.1, sample_shape=[data_size, units[2]], name="z2")
    z1 = ed.Gamma(shape, shape / tf.matmul(z2, w2),
                  name="z1")  # z1的形状跟着两个参数的形状跑,此处相当于对rate建模,concentration不建模
    z0 = ed.Gamma(shape, shape / tf.matmul(z1, w1), name="z0")
    x = ed.Poisson(tf.matmul(z0, w0), name="x")
    return x, w2, w1, w0, z2, z1, z0
Esempio n. 5
0
def latent_poisson(shape, rate):
    rate = tf.constant(rate, shape=shape)
    prior = ed.Poisson(rate=rate)
    return prior