code: def main(_):
      ed.set_seed(42)
  
      # DATA. MNIST batches are fed at training time.
      (x_train, _), (x_test, _) = mnist(FLAGS.data_dir)
      x_train_generator = generator(x_train, FLAGS.M)
      x_ph = tf.placeholder(tf.float32, [FLAGS.M, 784])
  
      # MODEL
      with tf.variable_scope("Gen"):
          eps = Uniform(
              low=tf.zeros([FLAGS.M, FLAGS.d]) - 1.0,
              high=tf.ones([FLAGS.M, FLAGS.d]),
          )
          x = generative_network(eps)
  
      # INFERENCE
      optimizer = tf.train.RMSPropOptimizer(learning_rate=5e-5)
      optimizer_d = tf.train.RMSPropOptimizer(learning_rate=5e-5)
  
      inference = ed.WGANInference(
          data={x: x_ph}, discriminator=discriminative_network
      )
      inference.initialize(
          optimizer=optimizer,
          optimizer_d=optimizer_d,
          n_iter=15000,
          n_print=1000,
          clip=0.01,
          penalty=None,
      )
  
      sess = ed.get_session()
      tf.global_variables_initializer().run()
  
      idx = np.random.randint(FLAGS.M, size=16)
      i = 0
      for t in range(inference.n_iter):
          if t % inference.n_print == 0:
              samples = sess.run(x)
              samples = samples[idx,]
  
              fig = plot(samples)
              plt.savefig(
                  os.path.join(FLAGS.out_dir, "{}.png").format(
                      str(i).zfill(3)
                  ),
                  bbox_inches="tight",
              )
              plt.close(fig)
              i += 1
  
          x_batch = next(x_train_generator)
          for _ in range(5):
              inference.update(
                  feed_dict={x_ph: x_batch}, variables="Disc"
              )
  
          info_dict = inference.update(
              feed_dict={x_ph: x_batch}, variables="Gen"
          )
          # note: not printing discriminative objective; `info_dict` above
          # does not store it since updating only "Gen"
          info_dict["t"] = (
              info_dict["t"] // 6
          )  # say set of 6 updates is 1 iteration
          inference.print_progress(info_dict)
  
file_path: edward/examples/gan_wasserstein.py
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import edward
  import matplotlib.pyplot
  import matplotlib.gridspec
  import numpy
  import os
  import tensorflow
  from edward.models import Uniform
  from observations import mnist
label_desc: Use image node_id 5 for calling a global function with example usage: main(_) without return types