code: def main(_):
      # Data generation (known mean)
      xn_data = np.random.normal(FLAGS.loc, FLAGS.scale, FLAGS.N)
      print("scale: {}".format(FLAGS.scale))
  
      # Prior definition
      alpha = 0.5
      beta = 0.7
  
      # Posterior inference
      # Probabilistic model
      ig = InverseGamma(alpha, beta)
      xn = Normal(FLAGS.loc, tf.sqrt(ig), sample_shape=FLAGS.N)
  
      # Inference
      qig = Empirical(
          params=tf.get_variable(
              "qig/params",
              [1000],
              initializer=tf.constant_initializer(0.5),
          )
      )
      proposal_ig = InverseGamma(2.0, 2.0)
      inference = ed.MetropolisHastings(
          {ig: qig}, {ig: proposal_ig}, data={xn: xn_data}
      )
      inference.run()
  
      sess = ed.get_session()
      print("Inferred scale: {}".format(sess.run(tf.sqrt(qig.mean()))))
  
file_path: edward/examples/invgamma_normal_mh.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import edward
  import numpy
  import tensorflow
  from edward.models import InverseGamma, Normal, Empirical
label_desc: Use image node_id 1 for calling a global function with example usage: main(_) without return types