class_docstr: Variational inference with the KL divergence
  
  $\text{KL}( p(z \mid x) \| q(z) ).$
  
  To perform the optimization, this class uses a technique from
  adaptive importance sampling [@oh1992adaptive].
  
  #### Notes
  
  `KLpq` also optimizes any model parameters $p(z\mid x;
  \theta)$. It does this by variational EM, maximizing
  
  $\mathbb{E}_{p(z \mid x; \lambda)} [ \log p(x, z; \theta) ]$
  
  with respect to $\theta$.
  
  In conditional inference, we infer $z` in $p(z, \beta
  \mid x)$ while fixing inference over $\beta$ using another
  distribution $q(\beta)$. During gradient calculation, instead
  of using the model's density
  
  $\log p(x, z^{(s)}), z^{(s)} \sim q(z; \lambda),$
  
  for each sample $s=1,\ldots,S$, `KLpq` uses
  
  $\log p(x, z^{(s)}, \beta^{(s)}),$
  
  where $z^{(s)} \sim q(z; \lambda)$ and$\beta^{(s)}
  \sim q(\beta)$.
  
  The objective function also adds to itself a summation over all
  tensors in the `REGULARIZATION_LOSSES` collection.
class_docstr_tok: ["Variational","inference","with","the","KL","divergence","$","\\text","{","KL","}","(","p","(","z","\\mid","x",")","\\|","q","(","z",")",")",".","$","To","perform","the","optimization",",","this","class","uses","a","technique","from","adaptive","importance","sampling","[","@","oh1992adaptive","]",".","#","#","#","#","Notes","`","KLpq","`","also","optimizes","any","model","parameters","$","p","(","z\\mid","x",";","\\theta",")","$",".","It","does","this","by","variational","EM",",","maximizing","$","\\mathbb","{","E","}","_","{","p","(","z","\\mid","x",";","\\lambda",")","}","[","\\log","p","(","x",",","z",";","\\theta",")","]","$","with","respect","to","$","\\theta","$",".","In","conditional","inference",",","we","infer","$","z","`","in","$","p","(","z",",","\\beta","\\mid","x",")","$","while","fixing","inference","over","$","\\beta","$","using","another","distribution","$","q","(","\\beta",")","$",".","During","gradient","calculation",",","instead","of","using","the","model","'s","density","$","\\log","p","(","x",",","z^","{","(","s",")","}",")",",","z^","{","(","s",")","}","\\sim","q","(","z",";","\\lambda",")",",","$","for","each","sample","$","s=1",",","\\ldots",",","S","$",",","`","KLpq","`","uses","$","\\log","p","(","x",",","z^","{","(","s",")","}",",","\\beta^","{","(","s",")","}",")",",","$","where","$","z^","{","(","s",")","}","\\sim","q","(","z",";","\\lambda",")","$","and","$","\\beta^","{","(","s",")","}","\\sim","q","(","\\beta",")","$",".","The","objective","function","also","adds","to","itself","a","summation","over","all","tensors","in","the","`","REGULARIZATION_LOSSES","`","collection","."]
docstr: Initialize inference algorithm. It initializes hyperparameters
  and builds ops for the algorithm's computation graph.
  
  Args:
    n_samples: int.
      Number of samples from variational model for calculating
      stochastic gradients.
docstr_tok: ["Initialize","inference","algorithm",".","It","initializes","hyperparameters","and","builds","ops","for","the","algorithm","'s","computation","graph",".","Args",":","n_samples",":","int",".","Number","of","samples","from","variational","model","for","calculating","stochastic","gradients","."]
code: def initialize(self, n_samples=1, *args, **kwargs):
      """Initialize inference algorithm. It initializes hyperparameters
      and builds ops for the algorithm's computation graph.
  
      Args:
        n_samples: int.
          Number of samples from variational model for calculating
          stochastic gradients.
      """
      if n_samples <= 0:
          raise ValueError(
              "n_samples should be greater than zero: {}".format(
                  n_samples
              )
          )
      self.n_samples = n_samples
      return super(KLpq, self).initialize(*args, **kwargs)
  
file_path: edward/edward/inferences/klpq.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import six
  import tensorflow
  from edward.inferences.variational_inference import VariationalInference
  from edward.models import RandomVariable
  from edward.util import copy, get_descendants
label_desc: Use image node_id 2 for calling the KLpq obj's underlying member method code with example usage: obj.initialize(n_samples) and returns: super