class_docstr: Variational AutoEncoder
docstr: Get loss function of VAE.
  
  The loss value is equal to ELBO (Evidence Lower Bound)
  multiplied by -1.
  
  Args:
      C (int): Usually this is 1.0. Can be changed to control the
          second term of ELBO bound, which works as regularization.
      k (int): Number of Monte Carlo samples used in encoded vector.
code: def get_loss_func(self, C=1.0, k=1):
      """Get loss function of VAE.
  
      The loss value is equal to ELBO (Evidence Lower Bound)
      multiplied by -1.
  
      Args:
          C (int): Usually this is 1.0. Can be changed to control the
              second term of ELBO bound, which works as regularization.
          k (int): Number of Monte Carlo samples used in encoded vector.
      """
  
      def lf(x):
          mu, ln_var = self.encode(x)
          batchsize = len(mu.data)
          # reconstruction loss
          rec_loss = 0
          for l in six.moves.range(k):
              z = F.gaussian(mu, ln_var)
              rec_loss += F.bernoulli_nll(
                  x, self.decode(z, sigmoid=False)
              ) / (k * batchsize)
          self.rec_loss = rec_loss
          self.loss = (
              self.rec_loss
              + C * gaussian_kl_divergence(mu, ln_var) / batchsize
          )
          return self.loss
  
      return lf
  
file_path: tensorboardX/examples/chainer/plain_logger/net.py
imports: import six
  import chainer
  import chainer.functions
  from chainer.functions.loss.vae import gaussian_kl_divergence
  import chainer.links
label_desc: Use image node_id 5 for calling the VAE obj's underlying member method code with example usage: obj.get_loss_func(C, k) and returns: lf, self