The discriminator

The first thing we need is to create our discriminator network. For this, we stack several fully connected layers together. The discriminator takes as input a batch of 784 length vectors, which is our 28x28 MNIST images flattened. The output will be just a single number for each image, which is the score of how confident the discriminator is with regard to that image being a real image. We use Leaky ReLu as the activation function to prevent ReLu units from dying out.

We return raw logits, as the loss function will apply the sigmoid activation function for us to ensure that our discriminator output is between 0 and 1:

def discriminator(x):
with tf.variable_scope("discriminator"):
fc1 = tf.layers.dense(inputs=x, units=256, activation=tf.nn.leaky_relu)
fc2 = tf.layers.dense(inputs=fc1, units=256, activation=tf.nn.leaky_relu)
logits = tf.layers.dense(inputs=fc2, units=1)
return logits

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

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