Ejemplo n.º 1
0
def convnet(inputs, cond, filters, hps, channels):
    inputs = tf.nn.relu(conv2d(inputs, width=filters, name="conv2d_1"))
    inputs = tf.nn.relu(
        conv2d(inputs, filters, filter_size=[1, 1], name="conv2d_2"))
    # 前两个卷积层通道数为c,使用ReLU激活函数,卷积核大小分别为3*3 和 1*1
    inputs = conv2d_zeros(inputs, channels, name="conv2d_3")
    return inputs
Ejemplo n.º 2
0
Archivo: layers.py Proyecto: gdahia/DLF
def split2d_prior(z, hps):
    n_z2 = int(z.get_shape()[3])
    n_z1 = n_z2

    h = conv2d_zeros(z, 2 * n_z1, name="conv")
    mean, logsd = tf.split(h, 2, axis=-1)

    rescale = tf.get_variable("rescale", [], initializer=tf.constant_initializer(1.))
    scale_shift = tf.get_variable("scale_shift", [], initializer=tf.constant_initializer(0.))
    logsd = tf.tanh(logsd) * rescale + scale_shift

    return gaussian_diag(mean, logsd)
Ejemplo n.º 3
0
def split2d_prior(z, hps):
    n_z2 = int(z.get_shape()[3])
    n_z1 = n_z2

    h = conv2d_zeros(z, 2 * n_z1, name="conv")
    mean, logsd = tf.split(h, 2, axis=-1)

    rescale = tf.get_variable("rescale", [],
                              initializer=tf.constant_initializer(1.))
    scale_shift = tf.get_variable("scale_shift", [],
                                  initializer=tf.constant_initializer(0.))
    logsd = tf.tanh(logsd) * rescale + scale_shift

    return gaussian_diag(mean, logsd)
Ejemplo n.º 4
0
Archivo: layers.py Proyecto: gdahia/DLF
def prior(y_onehot, hps, name=None):
    n_z = hps.top_shape[-1]

    h = tf.zeros([tf.shape(y_onehot)[0]]+hps.top_shape[:2]+[2*n_z])
    h = conv2d_zeros(h, 2*n_z, name="p")
    if hps.ycond:
        h += tf.reshape(linear_zeros(y_onehot, 2*n_z, name="y_emb"), [-1, 1, 1, 2 * n_z])
    mean, logsd = tf.split(h, 2, axis=-1)

    rescale = tf.get_variable("rescale", [], initializer=tf.constant_initializer(1.))
    scale_shift = tf.get_variable("scale_shift", [], initializer=tf.constant_initializer(0.))
    logsd = tf.tanh(logsd) * rescale + scale_shift

    pz = gaussian_diag(mean, logsd)
    logp = lambda z1: pz.logp(z1)
    eps = lambda z1: pz.get_eps(z1)
    sample = lambda eps: pz.sample(eps)

    return logp, sample, eps
Ejemplo n.º 5
0
def prior(y_onehot, hps, name=None):
    n_z = hps.top_shape[-1]

    h = tf.zeros([tf.shape(y_onehot)[0]] + hps.top_shape[:2] + [2 * n_z])
    h = conv2d_zeros(h, 2 * n_z, name="p")
    if hps.ycond:
        h += tf.reshape(linear_zeros(y_onehot, 2 * n_z, name="y_emb"),
                        [-1, 1, 1, 2 * n_z])
    mean, logsd = tf.split(h, 2, axis=-1)

    rescale = tf.get_variable("rescale", [],
                              initializer=tf.constant_initializer(1.))
    scale_shift = tf.get_variable("scale_shift", [],
                                  initializer=tf.constant_initializer(0.))
    logsd = tf.tanh(logsd) * rescale + scale_shift

    pz = gaussian_diag(mean, logsd)
    logp = lambda z1: pz.logp(z1)
    eps = lambda z1: pz.get_eps(z1)
    sample = lambda eps: pz.sample(eps)

    return logp, sample, eps
Ejemplo n.º 6
0
def convnet(inputs, cond, filters, hps, channels):
    inputs = tf.nn.relu(conv2d(inputs, width=filters, name="conv2d_1"))
    inputs = tf.nn.relu(
        conv2d(inputs, filters, filter_size=[1, 1], name="conv2d_2"))
    inputs = conv2d_zeros(inputs, channels, name="conv2d_3")
    return inputs
Ejemplo n.º 7
0
Archivo: layers.py Proyecto: gdahia/DLF
def convnet(inputs, cond, filters, hps, channels):
    inputs = tf.nn.relu(conv2d(inputs, width=filters, name="conv2d_1"))
    inputs = tf.nn.relu(conv2d(inputs, filters, filter_size=[1,1], name="conv2d_2"))
    inputs = conv2d_zeros(inputs, channels, name="conv2d_3")
    return inputs