Gpytorch: Incorporating additional data to train gp_model

Created on 15 Apr 2019  路  7Comments  路  Source: cornellius-gp/gpytorch

Hi,

I have a few questions regarding the incorporation of additional data to train the existing gp_model. As GP is a nonparametric algorithm which can learn as the data grows. Is there a way to incorporate additional data in gpytorch to update the hyperparameters without recalculating again using the whole data. I found two methods in GPyTorch which seems to be related to that :

get_fantasy_data() - problem with this is that the method is not available for multitask GPs
set_train_data()
My query is regarding the second method; in documentation, it is given that the function doesn't refit the hyperparameter. Does that mean it doesn't update the hyperparameters at all?

Thanks in advance!

question

All 7 comments

The hyperparameters don't have to be updated when you add new data. Updating them will give your model a better fit, but comes at the cost of additional computation.

GPyTorch doesn't fit the hyperparameters of GP models automatically - you have to write the optimization loop yourself (as seen in our examples). You should:

  • Condition your model on new data using set_train_data (and include the new data + all your old data)
  • Re-run the training loop (if you want to update the hyperparameters)

However, you may find for your particular application that the hyperparameters don't vary too much with new data - and it might make more sense to sparingly update the hyperparameters.

Closing this for now, but reopen if you have questions.

Hi,

I also have a similar question. I want to add more data to the training data but without updating the hyperparameters.
the problem is if I add an extra training point to the old data as you said I get a dimension error:

RuntimeError: Cannot modify shape of inputs (expected torch.Size([6, 1]), found torch.Size([7, 1])).

Also, the new training data should have a noise parameter equal to zero (i.e. I measure the data without error), contrary to the old data. How can I achieve that?

Thank you

You can use set_train_data(..., strict=False) to update with more data points.

To set the noise parameter, you can modify the noise parameter of the likelihood. If you just set it to zero you'll end up getting some numerical issues with posterior inference though, you'll want to use a small value instead.

thanks Balandat that worked,

I guess that to kernel of the covariance matrix, corresponding to the new data points, it is summed the same sigma value of all the other (training) points. Is there a way to avoid adding this noise to the new data points ( I am aware of the numerical difficulties that arise with zero noise, I'm going to add maybe just a small amount to the new datapoints to avoid that.)
thanks!

That's not easily possible with the same likelihood (the default one is homoskedastic). You could instead use a FixedNoiseGaussianLikelihood where you instantiate the first part of the vector of noises to the inferred noise level of your model and set the other ones to a very small noise level.

I used the FixedNoiseGaussianLikelihood. Do I have to re-initialize the GP model every time I add a new noise in the the likelihood? Because I get this error

GPInputWarning: You have passed data through a FixedNoiseGaussianLikelihood that did not match the size of the fixed noise, *and* you did not specify noise. This is treated as a no-op.

I am adding a new point and a new noise like this:

gp_model.set_train_data(new_train_x, new_train_y, strict=False)

likelihood.noise= torch.cat((likelihood.noise,torch.tensor([0.001])))

so the dimensions should match, but maybe is because the gp_model is using the likelihood function with which it was initialized?

Was this page helpful?
0 / 5 - 0 ratings