Open
Description
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 ??
Metadata
Metadata
Assignees
Labels
No labels