schematic gan implementation in this sectionwe'll explain how to implement gan in kerasin its barest form-because gans are advanceddiving deeply into the technical details would be out of scope for this book the specific implementation is deep convolutional gan (dcgan) gan where the generator and discriminator are deep convnets in particularit uses conv dtranspose layer for image upsampling in the generator you'll train the gan on images from cifar dataset of , rgb images belonging to classes ( , images per classto make things easieryou'll only use images belonging to the class "frog schematicallythe gan looks like this generator network maps vectors of shape (latent_dim,to images of shape ( discriminator network maps images of shape ( to binary score estimating the probability that the image is real gan network chains the generator and the discriminator togethergan(xdiscriminator(generator( )thus this gan network maps latent space vectors to the discriminator' assessment of the realism of these latent vectors as decoded by the generator you train the discriminator using examples of real and fake images along with "real"/"fakelabelsjust as you train any regular image-classification model to train the generatoryou use the gradients of the generator' weights with regard to the loss of the gan model this meansat every stepyou move the weights of the generator in direction that makes the discriminator more likely to classify as "realthe images decoded by the generator in other wordsyou train the generator to fool the discriminator bag of tricks the process of training gans and tuning gan implementations is notoriously difficult there are number of known tricks you should keep in mind like most things in deep learningit' more alchemy than sciencethese tricks are heuristicsnot theory-backed guidelines they're supported by level of intuitive understanding of the phenomenon at handand they're known to work well empiricallyalthough not necessarily in every context here are few of the tricks used in the implementation of the gan generator and discriminator in this section it isn' an exhaustive list of gan-related tipsyou'll find many more across the gan literaturewe use tanh as the last activation in the generatorinstead of sigmoidwhich is more commonly found in other types of models we sample points from the latent space using normal distribution (gaussian distribution)not uniform distribution licensed to