Defining the generator and discriminator

After defining the two main parts of our architecture that will be used to generate fake MNIST images (which will look exactly the same as the real ones), it's time to build the network using the functions that we have defined so far. In order to build the network, we are going to follow these steps:

  1. Defining the inputs for our model, which will consist of two variables. One of these variables will be the real images, which will be fed to the discriminator, and the second will be the latent space to be used by the generator to replicate the original images.
  2. Calling the defined generator function to build the generator part of the network.
  3. Calling the defined discriminator function to build the discriminator part of the network, but we are going to call this function twice. One call will be for the real data and the second call will be for the fake data from the generator.
  4. Keeping the weights of real and fake images the same by reusing the variables:
tf.reset_default_graph()

# creating the input placeholders for the discrminator and generator
real_discrminator_input, generator_input_z = inputs_placeholders(input_img_size, gen_z_size)

#Create the generator network
gen_model, gen_logits = generator(generator_input_z, input_img_size, gen_hidden_size, reuse_vars=False, leaky_relu_alpha=leaky_relu_alpha)

# gen_model is the output of the generator
#Create the generator network
disc_model_real, disc_logits_real = discriminator(real_discrminator_input, disc_hidden_size, reuse_vars=False, leaky_relu_alpha=leaky_relu_alpha)
disc_model_fake, disc_logits_fake = discriminator(gen_model, disc_hidden_size, reuse_vars=True, leaky_relu_alpha=leaky_relu_alpha)
..................Content has been hidden....................

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