Saving and loading Botorch models #1210
Replies: 3 comments 2 replies
-
I'm not sure whether we've tested saving/loading of the fully Bayesian models. They're doing a few things differently than standard models that could potentially be an issue here (e.g. first of all that the underlying |
Beta Was this translation helpful? Give feedback.
-
Nice catch, this hasn't been tested and currently isn't supported since |
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay here! This was fixed in #1384. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to store and retrieve a Botorch model. Specifically a SaasFullyBayesianSingleTaskGP.
I'm using the Gpytorch documentation to store and later load the state_dict into the model.
Saving:
torch.save(gp.state_dict(), 'model_state.pth')
pickle.dump([train_X, train_Y], open('train_data.pkl', 'wb'))
Loading:
train_X, train_Y = pickle.load(open('train_data.pkl', 'rb'))
state_dict = torch.load('data', 'model_state.pth')
gp = SaasFullyBayesianSingleTaskGP(train_X=train_X, train_Y=train_Y)
gp.load_state_dict(state_dict)
print(gp.state_dict())
>>OrderedDict()
That is, the state_dict is empty. Upon saving, the state_dict contains the trained parameters as expected.
The data state_dict is identical - but it seem to fail to load into the model.
I'm obviously doing something wrong. What is an effective way of storing and retrieving such models?
Thanks,
Daniel
Beta Was this translation helpful? Give feedback.
All reactions