code: def main(_):
      sns.set(color_codes=True)
      ed.set_seed(42)
  
      # DATA. We use a placeholder to represent a minibatch. During
      # inference, we generate data on the fly and feed `x_ph`.
      x_ph = tf.placeholder(tf.float32, [FLAGS.M, 1])
  
      # MODEL
      with tf.variable_scope("Gen"):
          eps = tf.linspace(
              -8.0, 8.0, FLAGS.M
          ) + 0.01 * tf.random_normal([FLAGS.M])
          eps = tf.reshape(eps, [-1, 1])
          x = generative_network(eps)
  
      # INFERENCE
      optimizer = tf.train.GradientDescentOptimizer(0.03)
      optimizer_d = tf.train.GradientDescentOptimizer(0.03)
  
      inference = ed.GANInference(
          data={x: x_ph}, discriminator=discriminative_network
      )
      inference.initialize(optimizer=optimizer, optimizer_d=optimizer_d)
      tf.global_variables_initializer().run()
  
      for _ in range(inference.n_iter):
          x_data = next_batch(FLAGS.M).reshape([FLAGS.M, 1])
          info_dict = inference.update(feed_dict={x_ph: x_data})
          inference.print_progress(info_dict)
  
      # CRITICISM
      db, pd, pg = get_samples(x_ph)
      db_x = np.linspace(-8, 8, len(db))
      p_x = np.linspace(-8, 8, len(pd))
      f, ax = plt.subplots(1)
      ax.plot(db_x, db, label="Decision boundary")
      ax.set_ylim(0, 1)
      plt.plot(p_x, pd, label="Real data")
      plt.plot(p_x, pg, label="Generated data")
      plt.title("1D Generative Adversarial Network")
      plt.xlabel("Data values")
      plt.ylabel("Probability density")
      plt.legend()
      plt.show()
  
file_path: edward/examples/gan_synthetic_data.py
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import edward
  import matplotlib.pyplot
  import numpy
  import seaborn
  import tensorflow
  from scipy.stats import norm
label_desc: Use image node_id 5 for calling a global function with example usage: main(_) without return types