Defining the generator

Generator takes the noise as an input and returns an image. We define the generator as a feedforward network with three layers. Instead of coding the generator network from scratch, we can use tf.layers.dense(), which can be used to create a dense layer. It takes three parameters: inputs, the number of units, and the activation function:

def generator(z,reuse=None):

with tf.variable_scope('generator',reuse=reuse):

hidden1 = tf.layers.dense(inputs=z,units=128,activation=tf.nn.leaky_relu)
hidden2 = tf.layers.dense(inputs=hidden1,units=128,activation=tf.nn.leaky_relu)
output = tf.layers.dense(inputs=hidden2,units=784,activation=tf.nn.tanh)

return output
..................Content has been hidden....................

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