generative deep learning the adversarial network finallyyou'll set up the ganwhich chains the generator and the discriminator when trainedthis model will move the generator in direction that improves its ability to fool the discriminator this model turns latent-space points into classification decision--"fakeor "real"--and it' meant to be trained with labels that are always "these are real images sotraining gan will update the weights of generator in way that makes discriminator more likely to predict "realwhen looking at fake images it' very important to note that you set the discriminator to be frozen during training (non-trainable)its weights won' be updated when training gan if the discriminator weights could be updated during this processthen you' be training the discriminator to always predict "real,which isn' what you wantlisting adversarial net work discriminator trainable false gan_input keras input(shape=(latent_dim,)gan_output discriminator(generator(gan_input)gan keras models model(gan_inputgan_outputsets discriminator weights to non-trainable (this will only apply to the gan modelgan_optimizer keras optimizers rmsprop(lr= clipvalue= decay= - gan compile(optimizer=gan_optimizerloss='binary_crossentropy'how to train your dcgan now you can begin training to recapitulatethis is what the training loop looks like schematically for each epochyou do the following draw random points in the latent space (random noisegenerate images with generator using this random noise mix the generated images with real ones train discriminator using these mixed imageswith corresponding targetseither "real(for the real imagesor "fake(for the generated imagesdraw new random points in the latent space train gan using these random vectorswith targets that all say "these are real images this updates the weights of the generator (onlybecause the discriminator is frozen inside ganto move them toward getting the discriminator to predict "these are real imagesfor generated imagesthis trains the generator to fool the discriminator let' implement it listing implement ing gan raining import os from keras preprocessing import image loads cifar data (x_trainy_train)(__keras datasets cifar load_data(licensed to