Skip to main content

FSPLaplace

FSPLaplace(
    kernel=None,
    epochs=1000,
    lr=0.01,
    train_context=400,
    posterior_context=10000,
    rank=256,
    jitter=0.001,
    restarts=10,
    context_bounds=(0.0, 1.0),
    noise=0.001,
)

Train under a GP prior over functions, then fit FSP-Laplace (Cinquin et al. 2024).

Each call works in three steps:

  1. An exact GP with kernel, a zero mean and the fixed noise tunes the kernel’s hyperparameters on the marginal likelihood, from restarts starting points.
  2. The network trains with Adam on the negative log-likelihood plus half the RKHS norm of its function under the tuned kernel, estimated at train_context points drawn uniformly anew in each step (lk.gp.rkhs_norm).
  3. lk.gp.fsp_laplace fits the posterior over all weights, constrained at posterior_context scrambled Sobol points.

The defaults follow the BO setup of the paper (its Appendix B.2): a Matérn-5/2 kernel, a few hundred training context points, and many low-discrepancy posterior context points. The posterior’s variance stays below the prior’s at the posterior context points only, so they must cover the search box densely; with too few, it can exceed the prior between them. Both sets of context points are drawn from the box context_bounds of every input, the unit box by default, as Normalize(d=d, bounds=bounds) makes it.

from gpytorch.kernels import PeriodicKernel, ScaleKernel

trainer = FSPLaplace(kernel=ScaleKernel(PeriodicKernel()))
model = LaplaceBoTorchSurrogate(
    make_net(),
    train_X,
    train_Y,
    trainer=trainer,
    input_transform=Normalize(d=1, bounds=bounds),
    outcome_transform=Standardize(m=1),
)

Parameters

Name Type Description Default
kernel gpytorch.kernels.Kernel | None The GPyTorch kernel of the prior, as to_lk_kernel takes it. It is copied in each call, and the copy is tuned. Its hyperpriors and constraints apply. None takes ScaleKernel(MaternKernel(nu=2.5, ard_num_dims=d)). None
epochs int Training steps, each on all the data. 1000
lr float Adam’s learning rate at the start of the cosine schedule. 0.01
train_context int Context points per training step. 400
posterior_context int Context points of the posterior. 10000
rank int The rank of the posterior, at most posterior_context. 256
jitter float The relative jitter of the prior covariance (lk.gp.FunctionPrior). A periodic kernel’s covariance is close to singular, and a smaller jitter can pin the network to a constant. 0.001
restarts int Starting points of the tune. The first is the kernel as given, the others draw its raw hyperparameters from a standard normal. 10
context_bounds tuple[float, float] The box (low, high) the context points are drawn from, in the space the network is trained in. (0.0, 1.0)
noise float The fixed noise variance, as a fraction of the outcomes’ variance, as in PosthocMarglik. A train_Yvar given to the surrogate takes its place. FSP needs a fixed noise, so None is refused. 0.001

Raises

Name Type Description
ValueError An option is not positive, rank is above posterior_context, or context_bounds is empty.