Model fitting routines., closure=None, optimizer=None, closure_kwargs=None, optimizer_kwargs=None, **kwargs)[source]

Clearing house for fitting models passed as GPyTorch MarginalLogLikelihoods.

  • mll (MarginalLogLikelihood) – A GPyTorch MarginalLogLikelihood instance.

  • closure (Callable[[], Tuple[Tensor, Sequence[Tensor | None]]] | None) – Forward-backward closure for obtaining objective values and gradients. Responsible for setting parameters’ grad attributes. If no closure is provided, one will be obtained by calling get_loss_closure_with_grads.

  • optimizer (Callable | None) – User specified optimization algorithm. When optimizer is None, this keyword argument is omitted when calling the dispatcher.

  • closure_kwargs (Dict[str, Any] | None) – Keyword arguments passed when calling closure.

  • optimizer_kwargs (Dict[str, Any] | None) – A dictionary of keyword arguments passed when calling optimizer.

  • **kwargs (Any) – Keyword arguments passed down through the dispatcher to fit subroutines. Unexpected keywords are ignored.


The mll instance. If fitting succeeded, then mll will be in evaluation mode, i.e. == False. Otherwise, mll will be in training mode.

Return type:

MarginalLogLikelihood, max_tree_depth=6, warmup_steps=512, num_samples=256, thinning=16, disable_progbar=False, jit_compile=False)[source]

Fit a fully Bayesian model using the No-U-Turn-Sampler (NUTS)

  • model (SaasFullyBayesianSingleTaskGP | SaasFullyBayesianMultiTaskGP) – SaasFullyBayesianSingleTaskGP to be fitted.

  • max_tree_depth (int) – Maximum tree depth for NUTS

  • warmup_steps (int) – The number of burn-in steps for NUTS.

  • num_samples (int) – The number of MCMC samples. Note that with thinning, num_samples / thinning samples are retained.

  • thinning (int) – The amount of thinning. Every nth sample is retained.

  • disable_progbar (bool) – A boolean indicating whether to print the progress bar and diagnostics during MCMC.

  • jit_compile (bool) – Whether to use jit. Using jit may be ~2X faster (rough estimate), but it will also increase the memory usage and sometimes result in runtime errors, e.g.,

Return type:



>>> gp = SaasFullyBayesianSingleTaskGP(train_X, train_Y)
>>> fit_fully_bayesian_model_nuts(gp)