Defining the Discriminator

 The discriminator is a simple convolution neural network binary classifier that takes in the image generated by the generator and tries to classify the image as original or fake. 

The first layer is a Convolution 2D layer with 64 filters of size 3*3  with activation as LeakyRelu and dropout as the regularizer. 

The second and third layers are same as the first layer except the second layer has 128 filters and the 3rd layer has 256 filters.

The final layer is a dense layer with sigmoid activation since we are doing a binary classification.

def img_discriminator(input_shape):
discriminator = Sequential()
discriminator.add(Conv2D(64, (3, 3), strides=2, padding='same', input_shape=input_shape, activation = 'linear'))
discriminator.add(LeakyReLU(0.2))
discriminator.add(Dropout(0.2))

discriminator.add(Conv2D(128, (3, 3), strides=2, padding='same', activation = 'linear'))
discriminator.add(LeakyReLU(0.2))
discriminator.add(Dropout(0.2))

discriminator.add(Conv2D(256, (3, 3), padding='same', activation = 'linear'))
discriminator.add(LeakyReLU(0.2))
discriminator.add(Dropout(0.2))

discriminator.add(Flatten())
discriminator.add(Dense(1, activation='sigmoid'))

return discriminator

# print summary of the discriminator
img_discriminator(input_shape).summary()
Figure 14.8: Summary of the Discriminator
Play around with the parameters of the discriminator to suit the needs of the problem you are trying to solve. Include MaxPooling layer in the model if needed.
..................Content has been hidden....................

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