Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to save SparseGP model #990

Open
quastarK opened this issue Aug 11, 2022 · 0 comments
Open

how to save SparseGP model #990

quastarK opened this issue Aug 11, 2022 · 0 comments

Comments

@quastarK
Copy link

hello i am trying to save and load SparseGPRegression model using the code

Saving models in a consistent way across versions:

let X, Y be data loaded above

Model creation:

m = GPy.models.GPRegression(X, Y)
m.optimize()
# 1: Saving a model:
np.save('model_save.npy', m.param_array)
# 2: loading a model
# Model creation, without initialization:
m_load = GPy.models.GPRegression(X, Y, initialize=False)
m_load.update_model(False) # do not call the underlying expensive algebra on load
m_load.initialize_parameter() # Initialize the parameters (connect the parameters up)
m_load[:] = np.load('model_save.npy') # Load the parameters
m_load.update_model(True) # Call the algebra only once
print(m_load)

My code :

sgp = GPy.models.SparseGPRegression(x_test, y_test, num_inducing=100,kernel=GPy.kern.RBF(5,ARD=True))
sgp.optimize()
np.save('smodel_save.npy', sgp.param_array)

m_load = GPy.models.SparseGPRegression(x_test, y_test, initialize=False)
m_load.update_model(False) # do not call the underlying expensive algebra on load
m_load.initialize_parameter() # Initialize the parameters (connect the parameters up)
m_load[:] = np.load('smodel_save.npy') # Load the parameters
m_load.update_model(True) # Call the algebra only once
print(m_load)

ValueError: Setting by slice or index only allowed with array-like

do you know how to make it works ??
does the above code work only for GPRegression model ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant