The only hyperparameter optimization library I've found that works with Keras functional API is Talos.
Does anyone know any others that would work?
The only hyperparameter optimization library I've found that works with Keras functional API is Talos.
Does anyone know any others that would work?
On
Talos seems doesn't work with the current TensorFlow version, simplest way we can do is to use the nested for loops function, but we will sacrifice the cross-validation part.
On
With KERAS functional API you can actually have GridSearchCV worked. Since grid only works for sequential, you only need to wrap the model with sequential layer.
model = Sequential()
model.add(Resnet50())
but do not forget to adjust your Keras model before adding and at the end add Dense model to map the results.
I have personally tried and run GridSearch and before finding this solution.
You can perform Keras Hyperparameter Tuning using Sklearn Grid Search with Cross Validation.
To perform Grid Search with Sequential Keras models (single-input only), you must turn these models into sklearn-compatible estimators by using Keras Wrappers for the Scikit-Learn API.
No need to do that from scratch, you can use Sequential Keras models as part of your Scikit-Learn workflow by implementing one of two wrappers from keras.wrappers.scikit_learnpackage:
Arguments
Example: Simple binary classification with Keras
Implement Keras Model creator function
We want to fine-tune these hyperparameters: optimizer, dropout_rate, kernel_init method and dense_layer_sizes.
These parameters must be defined in the signature of create_model() function with default parameters. You can add other hyperparameters if you want such as learning_rate, ...
binary_crossentropy is perfect for Two-class classification problem.
Create sklearn-like estimator
It’s a classification problem so we are using KerasClassifier wrapper.
Defining Hyperparamers Space
We define here our hyperparameters space including keras fit hyperparameters: epochs and batch_size:
And Finally Performing Grid Search with KFold Cross Validation