Generator class preparation

The first thing we'll do is prepare our class by following these steps:

  1.  The first step is to gather all of the packages we need to build the generator:
#!/usr/bin/env python3
import sys
import numpy as np
from keras.layers.advanced_activations import LeakyReLU
from keras.models import Sequential, Model
from keras.layers.convolutional import Conv3D, Deconv3D
from keras.layers import Input, BatchNormalization, Dense, Reshape
from keras.layers.core import Activation
from keras.optimizers import Adam, SGD
from keras.utils import plot_model
  1. Create the class with an input shape of our latent space and an optimizer of SGD:
class Generator(object):
def __init__(self, latent_size=100):

self.INPUT_SHAPE = (1, 1, 1, latent_size)
self.OPTIMIZER = SGD(lr=0.001, nesterov=True)

  1. For initialization, the final step is to create the model, compile, and produce a summary:
        self.Generator = self.model()
self.Generator.compile(loss='binary_crossentropy',
optimizer=self.OPTIMIZER)
self.summary()

We'll move on to creating the model method in the next step!

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

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