Ejemplo n.º 1
0
def generator_m2(z, heads=10, training=True, reuse=True, name="generator"):

    # Network Architecture is exactly same as in infoGAN (https://arxiv.org/abs/1606.03657)
    # Architecture : FC1024_BR-FC7x7x128_BR-(64)4dc2s_BR-(1)4dc2s_S
    with tf.variable_scope(name, reuse=reuse):
        net = tf.nn.relu(
            bn(linear(z, 1024, scope='g_fc1'),
               is_training=training,
               scope='g_bn1'))
        net = tf.nn.relu(
            bn(linear(net, 128 * 7 * 7, scope='g_fc2'),
               is_training=training,
               scope='g_bn2'))
        net = tf.reshape(net, [64, 7, 7, 128])
        net = tf.nn.relu(
            bn(deconv2d(net, [64, 14, 14, 64], 4, 4, 2, 2, name='g_dc3'),
               is_training=training,
               scope='g_bn3'))

        img_sets = []
        for i in range(heads):
            out = tf.nn.sigmoid(
                deconv2d(net, [64, 28, 28, 1],
                         4,
                         4,
                         2,
                         2,
                         name='g_dc4_h' + str(i)))
            img_sets.append(out)

        return img_sets
def info_discriminator(x, training=True, reuse=True, name="discriminator"):

    # Network Architecture is exactly same as in infoGAN (https://arxiv.org/abs/1606.03657)
    # Architecture : (64)4c2s-(128)4c2s_BL-FC1024_BL-FC1_S
    with tf.variable_scope(name, reuse=reuse):
        net = lrelu(conv2d(x, 64, 4, 4, 2, 2, name='d_conv1'))
        net = lrelu(bn(conv2d(net, 128, 4, 4, 2, 2, name='d_conv2'), is_training=training, scope='d_bn2'))
            # net = tf.reshape(net, [batch_size, -1])
            # net = lrelu(bn(linear(net, 1024, scope='d_fc3'), is_training=training, scope='d_bn3'))
        net = fc(net, 1024)
        net = lrelu(bn(net, is_training=training, scope='d_bn3'))
        out_logit = linear(net, 1, scope='d_fc4')
        out_logit2 = linear(net, 10, scope='d_fc5')
            # out = tf.nn.sigmoid(out_logit)

        return out_logit, out_logit2
def mgan_gen(z, heads=10,training=True, reuse=True, name = "generator"):
    with tf.variable_scope(name, reuse=reuse):
        net = tf.nn.relu(bn(linear(z, 4*4*512, scope='g_fc1'), is_training=training, scope='g_bn1'))
        # net = tf.nn.relu(bn(linear(net, 128 * 7 * 7, scope='g_fc2'), is_training=training, scope='g_bn2'))
        net = tf.reshape(net, [64, 4, 4, 512])
        net = tf.nn.relu(
            bn(deconv2d(net, [64, 8, 8, 256], 5, 5, 2, 2, name='g_dc2'), is_training=training,
               scope='g_bn2'))
        net = tf.nn.relu(
            bn(deconv2d(net, [64, 16, 16, 256], 5, 5, 2, 2, name='g_dc3'), is_training=training,
               scope='g_bn3'))
        img_sets = []
        for i in range(heads):
            out = tf.nn.sigmoid(deconv2d(net, [64, 32, 32, 3], 5, 5, 2, 2, name='g_dc4_h' + str(i)))
            img_sets.append(out)
        return img_sets
def generator_m2_32X32_dc(z, heads=10, training=True, reuse=True, name="generator"):

        # Network Architecture is exactly same as in infoGAN (https://arxiv.org/abs/1606.03657)
        # Architecture : FC1024_BR-FC7x7x128_BR-(64)4dc2s_BR-(1)4dc2s_S
    with tf.variable_scope(name, reuse=reuse):
        net = tf.nn.relu(bn(linear(z, 2048, scope='g_fc1'), is_training=training, scope='g_bn1'))
        net = tf.reshape(net, [64, 2, 2, 512])
        net = tf.nn.relu(
                bn(deconv2d(net, [64, 4, 4, 4*64], 4, 4, 2, 2, name='g_dc2'), is_training=training,
                   scope='g_bn2'))
        net = tf.nn.relu(
            bn(deconv2d(net, [64, 8, 8, 2 * 64], 4, 4, 2, 2, name='g_dc3'), is_training=training,
               scope='g_bn3'))
        net = tf.nn.relu(
            bn(deconv2d(net, [64, 16, 16, 2 * 64], 4, 4, 2, 2, name='g_dc4'), is_training=training,
               scope='g_bn4'))
        img_sets = []
        for i in range(heads):
            out = tf.nn.tanh(deconv2d(net, [64, 32, 32, 3], 4, 4, 2, 2, name='g_dc5_h' + str(i)))
            img_sets.append(out)

        return img_sets