class_docstr: Variational Gaussian Process model.
  
  This model deals with both Gaussian and non-Gaussian likelihoods. Given inputs\
  :math:`X` and their noisy observations :math:`y`, the model takes the form
  
  .. math::
      f &\sim \mathcal{GP}(0, k(X, X)),\\
      y & \sim p(y) = p(y \mid f) p(f),
  
  where :math:`p(y \mid f)` is the likelihood.
  
  We will use a variational approach in this model by approximating :math:`q(f)` to
  the posterior :math:`p(f\mid y)`. Precisely, :math:`q(f)` will be a multivariate
  normal distribution with two parameters ``f_loc`` and ``f_scale_tril``, which will
  be learned during a variational inference process.
  
  .. note:: This model can be seen as a special version of
      :class:`.VariationalSparseGP` model with :math:`X_u = X`.
  
  .. note:: This model has :math:`\mathcal{O}(N^3)` complexity for training,
      :math:`\mathcal{O}(N^3)` complexity for testing. Here, :math:`N` is the number
      of train inputs. Size of variational parameters is :math:`\mathcal{O}(N^2)`.
  
  :param torch.Tensor X: A input data for training. Its first dimension is the number
      of data points.
  :param torch.Tensor y: An output data for training. Its last dimension is the
      number of data points.
  :param ~pyro.contrib.gp.kernels.kernel.Kernel kernel: A Pyro kernel object, which
      is the covariance function :math:`k`.
  :param ~pyro.contrib.gp.likelihoods.likelihood Likelihood likelihood: A likelihood
      object.
  :param callable mean_function: An optional mean function :math:`m` of this Gaussian
      process. By default, we use zero mean.
  :param torch.Size latent_shape: Shape for latent processes (`batch_shape` of
      :math:`q(f)`). By default, it equals to output batch shape ``y.shape[:-1]``.
      For the multi-class classification problems, ``latent_shape[-1]`` should
      corresponse to the number of classes.
  :param bool whiten: A flag to tell if variational parameters ``f_loc`` and
      ``f_scale_tril`` are transformed by the inverse of ``Lff``, where ``Lff`` is
      the lower triangular decomposition of :math:`kernel(X, X)`. Enable this flag
      will help optimization.
  :param float jitter: A small positive term which is added into the diagonal part of
      a covariance matrix to help stablize its Cholesky decomposition.
class_docstr_tok: ["Variational","Gaussian","Process","model",".","This","model","deals","with","both","Gaussian","and","non-Gaussian","likelihoods",".","Given","inputs\\",":","math",":","`","X","`","and","their","noisy","observations",":","math",":","`","y","`",",","the","model","takes","the","form","..","math",":",":","f","&","\\sim","\\mathcal","{","GP","}","(","0",",","k","(","X",",","X",")",")",",","\\\\","y","&","\\sim","p","(","y",")","=","p","(","y","\\mid","f",")","p","(","f",")",",","where",":","math",":","`","p","(","y","\\mid","f",")","`","is","the","likelihood",".","We","will","use","a","variational","approach","in","this","model","by","approximating",":","math",":","`","q","(","f",")","`","to","the","posterior",":","math",":","`","p","(","f\\mid","y",")","`",".","Precisely",",",":","math",":","`","q","(","f",")","`","will","be","a","multivariate","normal","distribution","with","two","parameters","``","f_loc","``","and","``","f_scale_tril","``",",","which","will","be","learned","during","a","variational","inference","process",".","..","note",":",":","This","model","can","be","seen","as","a","special","version","of",":","class",":","`",".VariationalSparseGP","`","model","with",":","math",":","`","X_u","=","X","`",".","..","note",":",":","This","model","has",":","math",":","`","\\mathcal","{","O","}","(","N^3",")","`","complexity","for","training",",",":","math",":","`","\\mathcal","{","O","}","(","N^3",")","`","complexity","for","testing",".","Here",",",":","math",":","`","N","`","is","the","number","of","train","inputs",".","Size","of","variational","parameters","is",":","math",":","`","\\mathcal","{","O","}","(","N^2",")","`",".",":","param","torch.Tensor","X",":","A","input","data","for","training",".","Its","first","dimension","is","the","number","of","data","points",".",":","param","torch.Tensor","y",":","An","output","data","for","training",".","Its","last","dimension","is","the","number","of","data","points",".",":","param","~pyro.contrib.gp.kernels.kernel.Kernel","kernel",":","A","Pyro","kernel","object",",","which","is","the","covariance","function",":","math",":","`","k","`",".",":","param","~pyro.contrib.gp.likelihoods.likelihood","Likelihood","likelihood",":","A","likelihood","object",".",":","param","callable","mean_function",":","An","optional","mean","function",":","math",":","`","m","`","of","this","Gaussian","process",".","By","default",",","we","use","zero","mean",".",":","param","torch.Size","latent_shape",":","Shape","for","latent","processes","(","`","batch_shape","`","of",":","math",":","`","q","(","f",")","`",")",".","By","default",",","it","equals","to","output","batch","shape","``","y.shape","[",":","-1","]","``",".","For","the","multi-class","classification","problems",",","``","latent_shape","[","-1","]","``","should","corresponse","to","the","number","of","classes",".",":","param","bool","whiten",":","A","flag","to","tell","if","variational","parameters","``","f_loc","``","and","``","f_scale_tril","``","are","transformed","by","the","inverse","of","``","Lff","``",",","where","``","Lff","``","is","the","lower","triangular","decomposition","of",":","math",":","`","kernel","(","X",",","X",")","`",".","Enable","this","flag","will","help","optimization",".",":","param","float","jitter",":","A","small","positive","term","which","is","added","into","the","diagonal","part","of","a","covariance","matrix","to","help","stablize","its","Cholesky","decomposition","."]
code: def guide(self):
      self.set_mode("guide")
      self._load_pyro_samples()
  
      pyro.sample(
          self._pyro_get_fullname("f"),
          dist.MultivariateNormal(
              self.f_loc, scale_tril=self.f_scale_tril
          ).to_event(self.f_loc.dim() - 1),
      )
  
file_path: pyro/pyro/contrib/gp/models/vgp.py
imports: import torch
  from torch.distributions import constraints
  from torch.nn import Parameter
  import pyro
  import pyro.distributions
  from pyro.contrib.gp.models.model import GPModel
  from pyro.contrib.gp.util import conditional
  from pyro.distributions.util import eye_like
  from pyro.nn.module import PyroParam, pyro_method
label_desc: Use image node_id 3 for calling the VariationalGP obj's underlying member method code with example usage: obj.guide() without return types