bayeso.gp.gp_gpytorch

It is Gaussian process regression implementations with GPyTorch.

class bayeso.gp.gp_gpytorch.ExactGPModel(str_cov, prior_mu, X_train, Y_train, likelihood)

Bases: gpytorch.models.exact_gp.ExactGP

forward(X)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

bayeso.gp.gp_gpytorch.get_optimized_kernel(X_train: numpy.ndarray, Y_train: numpy.ndarray, prior_mu: Optional[callable], str_cov: str, fix_noise: bool = True, num_iters: int = 1000, debug: bool = False) → Tuple[numpy.ndarray, numpy.ndarray, dict]

This function computes the kernel matrix optimized by optimization method specified, its inverse matrix, and the optimized hyperparameters, using GPyTorch.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • prior_mu (function or NoneType) – prior mean function or None.
  • str_cov (str.) – the name of covariance function.
  • fix_noise (bool., optional) – flag for fixing a noise.
  • num_iters (int., optional) – the number of iterations for optimizing negative log likelihood.
  • debug (bool., optional) – flag for printing log messages.
Returns:

a tuple of kernel matrix over X_train, kernel matrix inverse, and dictionary of hyperparameters.

Return type:

tuple of (numpy.ndarray, numpy.ndarray, dict.)

Raises:

AssertionError, ValueError