class_docstr: Abstract base class for Monte Carlo. Specific Monte Carlo methods
  inherit from `MonteCarlo`, sharing methods in this class.
  
  To build an algorithm inheriting from `MonteCarlo`, one must at the
  minimum implement `build_update`: it determines how to assign
  the samples in the `Empirical` approximations.
  
  #### Notes
  
  The number of Monte Carlo iterations is set according to the
  minimum of all `Empirical` sizes.
  
  Initialization is assumed from `params[0, :]`. This generalizes
  initializing randomly and initializing from user input. Updates
  are along this outer dimension, where iteration t updates
  `params[t, :]` in each `Empirical` random variable.
  
  No warm-up is implemented. Users must run MCMC for a long period
  of time, then manually burn in the Empirical random variable.
  
  #### Examples
  
  Most explicitly, `MonteCarlo` is specified via a dictionary:
  
  ```python
  qpi = Empirical(params=tf.Variable(tf.zeros([T, K-1])))
  qmu = Empirical(params=tf.Variable(tf.zeros([T, K*D])))
  qsigma = Empirical(params=tf.Variable(tf.zeros([T, K*D])))
  ed.MonteCarlo({pi: qpi, mu: qmu, sigma: qsigma}, data)
  ```
  
  The inferred posterior is comprised of `Empirical` random
  variables with `T` samples. We also automate the specification
  of `Empirical` random variables. One can pass in a list of
  latent variables instead:
  
  ```python
  ed.MonteCarlo([beta], data)
  ed.MonteCarlo([pi, mu, sigma], data)
  ```
  
  It defaults to `Empirical` random variables with 10,000 samples for
  each dimension.
class_docstr_tok: ["Abstract","base","class","for","Monte","Carlo",".","Specific","Monte","Carlo","methods","inherit","from","`","MonteCarlo","`",",","sharing","methods","in","this","class",".","To","build","an","algorithm","inheriting","from","`","MonteCarlo","`",",","one","must","at","the","minimum","implement","`","build_update","`",":","it","determines","how","to","assign","the","samples","in","the","`","Empirical","`","approximations",".","#","#","#","#","Notes","The","number","of","Monte","Carlo","iterations","is","set","according","to","the","minimum","of","all","`","Empirical","`","sizes",".","Initialization","is","assumed","from","`","params","[","0",",",":","]","`",".","This","generalizes","initializing","randomly","and","initializing","from","user","input",".","Updates","are","along","this","outer","dimension",",","where","iteration","t","updates","`","params","[","t",",",":","]","`","in","each","`","Empirical","`","random","variable",".","No","warm-up","is","implemented",".","Users","must","run","MCMC","for","a","long","period","of","time",",","then","manually","burn","in","the","Empirical","random","variable",".","#","#","#","#","Examples","Most","explicitly",",","`","MonteCarlo","`","is","specified","via","a","dictionary",":","``","`","python","qpi","=","Empirical","(","params=tf.Variable","(","tf.zeros","(","[","T",",","K-1","]",")",")",")","qmu","=","Empirical","(","params=tf.Variable","(","tf.zeros","(","[","T",",","K","*","D","]",")",")",")","qsigma","=","Empirical","(","params=tf.Variable","(","tf.zeros","(","[","T",",","K","*","D","]",")",")",")","ed.MonteCarlo","(","{","pi",":","qpi",",","mu",":","qmu",",","sigma",":","qsigma","}",",","data",")","``","`","The","inferred","posterior","is","comprised","of","`","Empirical","`","random","variables","with","`","T","`","samples",".","We","also","automate","the","specification","of","`","Empirical","`","random","variables",".","One","can","pass","in","a","list","of","latent","variables","instead",":","``","`","python","ed.MonteCarlo","(","[","beta","]",",","data",")","ed.MonteCarlo","(","[","pi",",","mu",",","sigma","]",",","data",")","``","`","It","defaults","to","`","Empirical","`","random","variables","with","10,000","samples","for","each","dimension","."]
docstr: Run one iteration of sampling.
  
  Args:
    feed_dict: dict.
      Feed dictionary for a TensorFlow session run. It is used to feed
      placeholders that are not fed during initialization.
  
  Returns:
    dict.
    Dictionary of algorithm-specific information. In this case, the
    acceptance rate of samples since (and including) this iteration.
  
  #### Notes
  
  We run the increment of `t` separately from other ops. Whether the
  others op run with the `t` before incrementing or after incrementing
  depends on which is run faster in the TensorFlow graph. Running it
  separately forces a consistent behavior.
docstr_tok: ["Run","one","iteration","of","sampling",".","Args",":","feed_dict",":","dict",".","Feed","dictionary","for","a","TensorFlow","session","run",".","It","is","used","to","feed","placeholders","that","are","not","fed","during","initialization",".","Returns",":","dict",".","Dictionary","of","algorithm-specific","information",".","In","this","case",",","the","acceptance","rate","of","samples","since","(","and","including",")","this","iteration",".","#","#","#","#","Notes","We","run","the","increment","of","`","t","`","separately","from","other","ops",".","Whether","the","others","op","run","with","the","`","t","`","before","incrementing","or","after","incrementing","depends","on","which","is","run","faster","in","the","TensorFlow","graph",".","Running","it","separately","forces","a","consistent","behavior","."]
code: def update(self, feed_dict=None):
      """Run one iteration of sampling.
  
      Args:
        feed_dict: dict.
          Feed dictionary for a TensorFlow session run. It is used to feed
          placeholders that are not fed during initialization.
  
      Returns:
        dict.
        Dictionary of algorithm-specific information. In this case, the
        acceptance rate of samples since (and including) this iteration.
  
      #### Notes
  
      We run the increment of `t` separately from other ops. Whether the
      others op run with the `t` before incrementing or after incrementing
      depends on which is run faster in the TensorFlow graph. Running it
      separately forces a consistent behavior.
      """
      if feed_dict is None:
          feed_dict = {}
  
      for key, value in six.iteritems(self.data):
          if (
              isinstance(key, tf.Tensor)
              and "Placeholder" in key.op.type
          ):
              feed_dict[key] = value
  
      sess = get_session()
      _, accept_rate = sess.run(
          [self.train, self.n_accept_over_t], feed_dict
      )
      t = sess.run(self.increment_t)
  
      if self.debug:
          sess.run(self.op_check, feed_dict)
  
      if self.logging and self.n_print != 0:
          if t == 1 or t % self.n_print == 0:
              summary = sess.run(self.summarize, feed_dict)
              self.train_writer.add_summary(summary, t)
  
      return {"t": t, "accept_rate": accept_rate}
  
file_path: edward/edward/inferences/monte_carlo.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import numpy
  import six
  import tensorflow
  from edward.inferences.inference import Inference
  from edward.models import Empirical, RandomVariable
  from edward.util import get_session
label_desc: Use image node_id 3 for calling the MonteCarlo obj's underlying member method code with example usage: obj.update(feed_dict) and returns: dict