Generator initialization

The Generator class needs to have a few input variables such as the width, height, and channels of the input data. The latent space is also important as it helps define the size of the distribution that we will sample and the side of the neural network. The code is as follows:

class Generator(object):
def __init__(self, width = 28, height= 28, channels = 1,
latent_size=100):
self.W = width
self.H = height
self.C = channels
self.OPTIMIZER = Adam(lr=0.0002, decay=8e-9)

self.LATENT_SPACE_SIZE = latent_size
self.latent_space = np.random.normal(0,1,
(self.LATENT_SPACE_SIZE,))

self.Generator = self.model()
self.Generator.compile(loss='binary_crossentropy',
optimizer=self.OPTIMIZER)
self.Generator.summary()

A few of the variables are defined within the class such as the height, width, and channels. The optimizer is instantiated and the latent space is defined. Finally, every time we call a generator object, we want it to build and compile itself. When it is complete, it will print a summary of the model built by these steps.

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

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