user11529747
user11529747

Reputation:

Save a model with keras

I use the method save_model and load_mode but it don't work.

I have an error : AttributeError: 'GridSearchCV' object has no attribute 'get_config' I don't know if I use correctly this method. I show my code for take an example:

gridSearch = GridSearchCV(estimator = classifier,
                          param_grid = parameters,
                          scoring = "accuracy",
                          cv = 10)
gridSearch.fit(X_train, y_train)
save_model(gridSearch, filepath = 'monModele.h5')

The result is the error attribute Error. Can you help me to find a solution for this problem or to find an other method to save and load a keras model.

Upvotes: 1

Views: 217

Answers (1)

nuric
nuric

Reputation: 11225

That is because GridSearchCV is not a Keras model, but a module from sklearn that also has a fit function with a similar API.

In order to use save_model and load_model you need the actual Keras model, my guess is it is your classifier. Specifically, an instance of the Model class from Keras.

Upvotes: 3

Related Questions