def Discriminator(y_dash, dropout=0.4, lr=0.00001, PATH="Dis.h5"):
"""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."""
model = Sequential()
model.add(Conv1D(input_shape=(y_dash.shape[1], y_dash.shape[2]),
nb_filter=25,
filter_length=4,
border_mode='same'))
model.add(LeakyReLU())
model.add(Dropout(dropout))
model.add(MaxPooling1D())
model.add(Conv1D(nb_filter=10,
filter_length=4,
border_mode='same'))
model.add(LeakyReLU())
model.add(Dropout(dropout))
model.add(MaxPooling1D())
model.add(Flatten())
model.add(Dense(64))
model.add(LeakyReLU())
model.add(Dropout(dropout))
model.add(Dense(1))
model.add(Activation('linear'))
opt = Adam(lr, beta_1=0.5, beta_2=0.9)
#reduce_lr = ReduceLROnPlateau(monitor='val_acc', factor=0.9, patience=30, min_lr=0.000001, verbose=1)
checkpoint_D = ModelCheckpoint(
filepath=PATH, verbose=1, save_best_only=True)
model.compile(optimizer=opt,
loss=wasserstein_loss,
metrics=['accuracy'])
return model, checkpoint_D
评论列表
文章目录