Helper methods of the generator

Helper methods make things in a class more efficient or frequently used throughout the method. In our case, it seemed important to ensure that we could check the structure of the model as a text output and graphically:

  1. The text summary available from Keras is easy to implement:
def summary(self):
return self.Generator.summary()
  1. The summary function should return an output in the Terminal like this once we use the Generator class:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, 128) 12928
_________________________________________________________________
leaky_re_lu_1 (LeakyReLU) (None, 128) 0
_________________________________________________________________
batch_normalization_1 (Batch (None, 128) 512
_________________________________________________________________
dense_2 (Dense) (None, 256) 33024
_________________________________________________________________
leaky_re_lu_2 (LeakyReLU) (None, 256) 0
_________________________________________________________________
batch_normalization_2 (Batch (None, 256) 1024
_________________________________________________________________
dense_3 (Dense) (None, 512) 131584
_________________________________________________________________
leaky_re_lu_3 (LeakyReLU) (None, 512) 0
_________________________________________________________________
batch_normalization_3 (Batch (None, 512) 2048
_________________________________________________________________
dense_4 (Dense) (None, 1024) 525312
_________________________________________________________________
leaky_re_lu_4 (LeakyReLU) (None, 1024) 0
_________________________________________________________________
batch_normalization_4 (Batch (None, 1024) 4096
_________________________________________________________________
dense_5 (Dense) (None, 784) 803600
_________________________________________________________________
reshape_1 (Reshape) (None, 28, 28, 1) 0
=================================================================
Total params: 1,514,128
Trainable params: 1,510,288
Non-trainable params: 3,840
_________________________________________________________________
  1. Next, let's go over the generator's version of the model saver. This function is identical to the function inside of the Discriminator, except for the path:
def save_model(self):
plot_model(self.Discriminator.model,
to_file='/data/Discriminator_Model.png')

This function will output a PNG in the data folder that represents the structure of the model:


So, this was how we built the GAN generator. I hope you found it easy. We are now ready to make a masterpiece.

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

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