我正在关注本教程,并且可以使用我的 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)