【问题标题】:Face Generation TensorFlow increase size from 28px conv2d_transposeFace Generation TensorFlow 将尺寸从 28px conv2d_transpose 增加
【发布时间】:2019-02-19 09:18:41
【问题描述】:

我正在关注this tutorial,并且可以使用我的 GPU 成功生成 28 像素大小的人脸。但是我不知道如何使用下面的生成器函数的逻辑来增加人脸的大小(目前为 28px):

def generator(z, out_channel_dim, is_train=True, alpha=0.2, keep_prob=0.5):
    with tf.variable_scope('generator', reuse=(not is_train)):
        # First fully connected layer, 4x4x1024
        fc = tf.layers.dense(z, 4 * 4 * 1024, use_bias=False)
        fc = tf.reshape(fc, (-1, 4, 4, 1024))
        bn0 = tf.layers.batch_normalization(fc, training=is_train)
        lrelu0 = tf.maximum(alpha * bn0, bn0)
        drop0 = tf.layers.dropout(lrelu0, keep_prob, training=is_train)

        # Deconvolution, 7x7x512
        conv1 = tf.layers.conv2d_transpose(drop0, 512, 4, 1, 'valid', use_bias=False)
        bn1 = tf.layers.batch_normalization(conv1, training=is_train)
        lrelu1 = tf.maximum(alpha * bn1, bn1)
        drop1 = tf.layers.dropout(lrelu1, keep_prob, training=is_train)

        # Deconvolution, 14x14x256
        conv2 = tf.layers.conv2d_transpose(drop1, 256, 5, 2, 'same', use_bias=False)
        bn2 = tf.layers.batch_normalization(conv2, training=is_train)
        lrelu2 = tf.maximum(alpha * bn2, bn2)
        drop2 = tf.layers.dropout(lrelu2, keep_prob, training=is_train)

        # Output layer, 28x28xn
        logits = tf.layers.conv2d_transpose(drop2, out_channel_dim, 5, 2, 'same')

        out = tf.tanh(logits)

        return out

我认为我需要更改以下内容:

conv2 = tf.layers.conv2d_transpose(drop1, 256, 5, 2, 'same', use_bias=False)

【问题讨论】:

    标签: python-3.x tensorflow tensorflow-datasets generative-adversarial-network


    【解决方案1】:

    应该在最后一层logits 上进行更改,因为那是决定输出大小的层。将out_channel_dim 值更改为您想要的大小将是解决方案。这可能会导致一些错误(由于内核大小和步幅值)或结果将不同(因为您的网络没有针对此大小进行训练)。

    【讨论】:

      猜你喜欢
      • 2015-07-01
      • 2021-10-06
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      • 2018-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多