Defining the DCGAN

The function below, pipes the input followed by the generator, followed by the discriminator to form the DCGAN architecture.

def dcgan(discriminator, generator, input_shape):
# Set discriminator as non trainable before compiling GAN
discriminator.trainable = False

# Accepts the noised input
gan_input = Input(shape=input_shape)

# Generates image by passing the above received input to the generator
gen_img = generator(gan_input)

# Feeds the generated image to the discriminator
gan_output = discriminator(gen_img)

# Compile everything as a model with binary crossentropy loss
gan = Model(inputs=gan_input, outputs=gan_output)
return gan

If you have not seen how to use the Model function API before, please visit the detailed documentation by Keras on using the Model function API and compiling it here https://keras.io/models/model/

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.120.57