class_docstr: A generic Linear Gaussian State Space Model parameterized with arbitrary time invariant
  transition and observation dynamics together with separate Gaussian Process noise models
  for each output dimension. In more detail, the generative process is:
  
      :math:`y_i(t) = \sum_j A_{ij} z_j(t) + f_i(t) + \epsilon_i(t)`
  
  where the latent variables :math:`{\bf z}(t)` follow generic time invariant Linear Gaussian dynamics
  and the :math:`f_i(t)` are Gaussian Processes with Matern kernels.
  
  The targets are (implicitly) assumed to be evenly spaced in time. In particular a timestep of
  :math:`dt=1.0` for the continuous-time GP dynamics corresponds to a single discrete step of
  the :math:`{\bf z}`-space dynamics. Training and inference are logarithmic in the length of
  the time series T.
  
  :param int obs_dim: The dimension of the targets at each time step.
  :param int state_dim: The dimension of the :math:`{\bf z}` latent state at each time step.
  :param float nu: The order of the Matern kernel; one of 0.5, 1.5 or 2.5.
  :param torch.Tensor length_scale_init: optional initial values for the kernel length scale
      given as a ``obs_dim``-dimensional tensor
  :param torch.Tensor kernel_scale_init: optional initial values for the kernel scale
      given as a ``obs_dim``-dimensional tensor
  :param torch.Tensor obs_noise_scale_init: optional initial values for the observation noise scale
      given as a ``obs_dim``-dimensional tensor
  :param bool learnable_observation_loc: whether the mean of the observation model should be learned or not;
          defaults to False.
class_docstr_tok: ["A","generic","Linear","Gaussian","State","Space","Model","parameterized","with","arbitrary","time","invariant","transition","and","observation","dynamics","together","with","separate","Gaussian","Process","noise","models","for","each","output","dimension",".","In","more","detail",",","the","generative","process","is",":",":","math",":","`","y_i","(","t",")","=","\\sum_j","A_","{","ij","}","z_j","(","t",")","+","f_i","(","t",")","+","\\epsilon_i","(","t",")","`","where","the","latent","variables",":","math",":","`","{","\\bf","z","}","(","t",")","`","follow","generic","time","invariant","Linear","Gaussian","dynamics","and","the",":","math",":","`","f_i","(","t",")","`","are","Gaussian","Processes","with","Matern","kernels",".","The","targets","are","(","implicitly",")","assumed","to","be","evenly","spaced","in","time",".","In","particular","a","timestep","of",":","math",":","`","dt=1.0","`","for","the","continuous-time","GP","dynamics","corresponds","to","a","single","discrete","step","of","the",":","math",":","`","{","\\bf","z","}","`","-space","dynamics",".","Training","and","inference","are","logarithmic","in","the","length","of","the","time","series","T.",":","param","int","obs_dim",":","The","dimension","of","the","targets","at","each","time","step",".",":","param","int","state_dim",":","The","dimension","of","the",":","math",":","`","{","\\bf","z","}","`","latent","state","at","each","time","step",".",":","param","float","nu",":","The","order","of","the","Matern","kernel",";","one","of","0.5",",","1.5","or","2.5.",":","param","torch.Tensor","length_scale_init",":","optional","initial","values","for","the","kernel","length","scale","given","as","a","``","obs_dim","``","-dimensional","tensor",":","param","torch.Tensor","kernel_scale_init",":","optional","initial","values","for","the","kernel","scale","given","as","a","``","obs_dim","``","-dimensional","tensor",":","param","torch.Tensor","obs_noise_scale_init",":","optional","initial","values","for","the","observation","noise","scale","given","as","a","``","obs_dim","``","-dimensional","tensor",":","param","bool","learnable_observation_loc",":","whether","the","mean","of","the","observation","model","should","be","learned","or","not",";","defaults","to","False","."]
code: def __init__(
      self,
      obs_dim=1,
      state_dim=2,
      nu=1.5,
      obs_noise_scale_init=None,
      length_scale_init=None,
      kernel_scale_init=None,
      learnable_observation_loc=False,
  ):
      self.obs_dim = obs_dim
      self.state_dim = state_dim
      self.nu = nu
  
      if obs_noise_scale_init is None:
          obs_noise_scale_init = 0.2 * torch.ones(obs_dim)
      assert obs_noise_scale_init.shape == (obs_dim,)
  
      super().__init__()
  
      self.kernel = MaternKernel(
          nu=nu,
          num_gps=obs_dim,
          length_scale_init=length_scale_init,
          kernel_scale_init=kernel_scale_init,
      )
      self.dt = 1.0
      self.full_state_dim = self.kernel.state_dim * obs_dim + state_dim
      self.full_gp_state_dim = self.kernel.state_dim * obs_dim
  
      self.obs_noise_scale = PyroParam(
          obs_noise_scale_init, constraint=constraints.positive
      )
      self.trans_noise_scale_sq = PyroParam(
          torch.ones(state_dim), constraint=constraints.positive
      )
      self.z_trans_matrix = nn.Parameter(
          torch.eye(state_dim)
          + 0.03 * torch.randn(state_dim, state_dim)
      )
      self.z_obs_matrix = nn.Parameter(
          0.3 * torch.randn(state_dim, obs_dim)
      )
      self.init_noise_scale_sq = PyroParam(
          torch.ones(state_dim), constraint=constraints.positive
      )
  
      gp_obs_matrix = torch.zeros(
          self.kernel.state_dim * obs_dim, obs_dim
      )
      for i in range(obs_dim):
          gp_obs_matrix[self.kernel.state_dim * i, i] = 1.0
      self.register_buffer("gp_obs_matrix", gp_obs_matrix)
  
      self.obs_selector = torch.tensor(
          [self.kernel.state_dim * d for d in range(obs_dim)],
          dtype=torch.long,
      )
  
      if learnable_observation_loc:
          self.obs_loc = nn.Parameter(torch.zeros(obs_dim))
      else:
          self.register_buffer("obs_loc", torch.zeros(obs_dim))
  
file_path: pyro/pyro/contrib/timeseries/lgssmgp.py
imports: import torch
  import torch.nn
  from torch.distributions import MultivariateNormal, constraints
  import pyro.distributions
  from pyro.contrib.timeseries.base import TimeSeriesModel
  from pyro.nn import PyroParam, pyro_method
  from pyro.ops.ssm_gp import MaternKernel
  from pyro.ops.tensor_utils import block_diag_embed, repeated_matmul
label_desc: Use image node_id 1 to create a new GenericLGSSMWithGPNoiseModel object from inherited base classes: TimeSeriesModel with example: obj = GenericLGSSMWithGPNoiseModel(obs_dim, state_dim, nu, obs_noise_scale_init, length_scale_init, kernel_scale_init, learnable_observation_loc)