def append_gan_network(self, true_X_input):
# Normalize the inputs via custom VGG Normalization layer
x = Normalize(type="gan", value=127.5, name="gan_normalize")(true_X_input)
x = Convolution2D(64, self.k, self.k, border_mode='same', name='gan_conv1_1')(x)
x = LeakyReLU(0.3, name="gan_lrelu1_1")(x)
x = Convolution2D(64, self.k, self.k, border_mode='same', name='gan_conv1_2', subsample=(2, 2))(x)
x = LeakyReLU(0.3, name='gan_lrelu1_2')(x)
x = BatchNormalization(mode=self.mode, axis=channel_axis, name='gan_batchnorm1_1')(x)
filters = [128, 256] if self.small_model else [128, 256, 512]
for i, nb_filters in enumerate(filters):
for j in range(2):
subsample = (2, 2) if j == 1 else (1, 1)
x = Convolution2D(nb_filters, self.k, self.k, border_mode='same', subsample=subsample,
name='gan_conv%d_%d' % (i + 2, j + 1))(x)
x = LeakyReLU(0.3, name='gan_lrelu_%d_%d' % (i + 2, j + 1))(x)
x = BatchNormalization(mode=self.mode, axis=channel_axis, name='gan_batchnorm%d_%d' % (i + 2, j + 1))(x)
x = Flatten(name='gan_flatten')(x)
output_dim = 128 if self.small_model else 1024
x = Dense(output_dim, name='gan_dense1')(x)
x = LeakyReLU(0.3, name='gan_lrelu5')(x)
gan_regulrizer = AdversarialLossRegularizer(weight=self.adversarial_loss_weight)
x = Dense(2, activation="softmax", activity_regularizer=gan_regulrizer, name='gan_output')(x)
return x
models.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录