pythongpflow

How can I transfer parameters from one gpflow model to another to gain similar results?


Suppose I have a trained model

m = gpflow.models.SVGP(
     likelihood=likelihood, kernel=kernel, inducing_variable=Z, num_data = len(X_train)
)

is it possible to transfer its parameters to another model and achieve similar results? For example

model = gpflow.models.SVGP(kernel=m.kernel,
                           likelihood=m.likelihood,
                           inducing_variable=m.inducing_variable,
                           num_data=m.num_data)

But this example fails since model has poor results. Are there some other parameters, which should be added to the signature, or it is impossible in principle?


Solution

  • Yes, the SVGP (as well as VGP) model predictions crucially depend on the q(u) distribution parametrised by model.q_mu and model.q_sqrt. You can transfer all parameters (including those two) using

    params = gpflow.utilities.parameter_dict(model)
    gpflow.utilities.multiple_assign(model, params)
    

    (see this notebook for more context)