Generator, G, takes the noise, , and also the conditional variable, , as an input and returns an image. We define the generator as a simple two- layer feed-forward network:
def generator(z, c,reuse=False):
with tf.variable_scope('generator', reuse=reuse):
Initialize the weights:
w_init = tf.contrib.layers.xavier_initializer()
Concatenate the noise, , and the conditional variable, :
inputs = tf.concat([z, c], 1)
Define the first layer:
dense1 = tf.layers.dense(inputs, 128, kernel_initializer=w_init)
relu1 = tf.nn.relu(dense1)
Define the second layer and compute the output with the tanh activation function:
logits = tf.layers.dense(relu1, 784, kernel_initializer=w_init)
output = tf.nn.tanh(logits)
return output