Discriminator

The Discriminator class involves similar changes to those seen in Chapter 3, My First GAN in Under 100 Lines. However, there are two significant differences: the if statement in the initialization step and the method for the model instantiation.

Note that we will go over these new pieces of code in detail in later chapters.

Now, let's take a look at a simple discriminator pseudocode example by using the following steps:

  1. As with the generator example, use python3 and perform the necessary imports, as follows:
#!/usr/bin/env python3
imports
  1. Create a class called Discriminator that allows you to toggle the model_type, as follows:
class Discriminator(object):
def __init__(self, width = 28, height= 28, channels = 1, latent_size=100, model_type = 'simple'):
# Initialize Class Variables
  1. Stub out the model type selector in the initialization step of the class, as follows:
if model_type=='simple':
# Initialize Simple Generator
elif model_type=='DCGAN':
# Initialize Convolutional Generator

  1. Create a method that develops the dc_model, as follows:
def dc_model(self):
# Convolutional Generator
return model
  1. Maintain the following original model from the previous chapter:
def model(self, block_starting_size=128,num_blocks=4):
# Simple GAN
return model
  1. Finally, input the following helper functions for the Discriminator function:
def summary(self):
# Summary Helper Function

def save_model(self):
# Model Saver Helper Function
..................Content has been hidden....................

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