Model development

The generator network is a model based on a few res_net blocks and an output layer. The following steps will build the generator network:

  1. Build the model with an input layer and the first 2D convolution layer, as follows
def model(self):
# Input
input_layer = Input(shape=self.SHAPE)
x = Convolution2D(64, 3,3, border_mode='same',activation='relu')(input_layer)
  1. Take a look at the first ResNet block, as follows:
# ResNet Block 1
res_x_input_1 = Conv2D(64, (3,3), border_mode='same',activation='relu')(x)
x = Convolution2D(64, 3,3, border_mode='same',activation='relu')
(res_x_input_1)
x = layers.Add()([res_x_input_1,x])
x = Activation('relu')(x)
  1. Add three more ResNet blocks to this network architecture, as follows:
# ResNet Block 2
res_x_input_2 = Conv2D(64, (3,3), border_mode='same',activation='relu')(x)
x = Convolution2D(64, 3,3, border_mode='same',activation='relu')
(res_x_input_2)
x = layers.Add()([res_x_input_2,x])
x = Activation('relu')(x)

# ResNet Block 3
res_x_input_3 = Conv2D(64, (3,3), border_mode='same',activation='relu')(x)
x = Convolution2D(64, 3,3, border_mode='same',activation='relu')
(res_x_input_3)
x = layers.Add()([res_x_input_3,x])
x = Activation('relu')(x)

# ResNet Block 4
res_x_input_4 = Conv2D(64, (3,3), border_mode='same',activation='relu')(x)
x = Convolution2D(64, 3,3, border_mode='same',activation='relu')
(res_x_input_4)
x = layers.Add()([res_x_input_4,x])
x = Activation('relu')(x)
  1. Build the model with the input and output later with the following code:
output_layer = Convolution2D(self.C,1,1, border_mode='same',activation='tanh')
(x)
return Model(input_layer,output_layer)

There are a few helper functions that we'll need to add into the class, so let's take a look at them!

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

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