Example of WGAN with TensorFlow

This example can be considered a variant of the previous one because it uses the same dataset, generator, and discriminator. The only main difference is that in this case, the discriminator (together with its variable scope) has been renamed critic():

import tensorflow as tfdef critic(x, is_training=True, reuse_variables=True):    with tf.variable_scope('critic', reuse=reuse_variables):...

At this point, we can step directly to the creation of the Graph containing all of the placeholders, operations, and loss functions:

import tensorflow as tfgraph = tf.Graph()with graph.as_default():    input_x = tf.placeholder(tf.float32, shape=(None, width, height, 1)) input_z = tf.placeholder(tf.float32, shape=(None, code_length)) ...

Get Mastering Machine Learning Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.