Utilities for model fitting., optimizer=<function fit_gpytorch_scipy>, **kwargs)[source]

Fit hyperparameters of a GPyTorch model.

On optimizer failures, a new initial condition is sampled from the hyperparameter priors and optimization is retried. The maximum number of retries can be passed in as a max_retries kwarg (default is 5).

Optimizer functions are in

  • mll (gpytorch.mlls.marginal_log_likelihood.MarginalLogLikelihood) – MarginalLogLikelihood to be maximized.

  • optimizer (Callable) – The optimizer function.

  • kwargs (Any) – Arguments passed along to the optimizer function, including max_retries and sequential (controls the fitting of ModelListGP and BatchedMultiOutputGPyTorchModel models) or approx_mll (whether to use gpytorch’s approximate MLL computation).


MarginalLogLikelihood with optimized parameters.

Return type



>>> gp = SingleTaskGP(train_X, train_Y)
>>> mll = ExactMarginalLogLikelihood(gp.likelihood, gp)
>>> fit_gpytorch_model(mll)