def make_discriminator():
"""Creates a discriminator model that takes an image as input and outputs a single value, representing whether
the input is real or generated. Unlike normal GANs, the output is not sigmoid and does not represent a probability!
Instead, the output should be as large and negative as possible for generated inputs and as large and positive
as possible for real inputs.
Note that the improved WGAN paper suggests that BatchNormalization should not be used in the discriminator."""
model = Sequential()
if K.image_data_format() == 'channels_first':
model.add(Convolution2D(64, (5, 5), padding='same', input_shape=(1, 28, 28)))
else:
model.add(Convolution2D(64, (5, 5), padding='same', input_shape=(28, 28, 1)))
model.add(LeakyReLU())
model.add(Convolution2D(128, (5, 5), kernel_initializer='he_normal', strides=[2, 2]))
model.add(LeakyReLU())
model.add(Convolution2D(128, (5, 5), kernel_initializer='he_normal', padding='same', strides=[2, 2]))
model.add(LeakyReLU())
model.add(Flatten())
model.add(Dense(1024, kernel_initializer='he_normal'))
model.add(LeakyReLU())
model.add(Dense(1, kernel_initializer='he_normal'))
return model
评论列表
文章目录