Closed sagihaider closed 4 years ago
@sagihaider, thanks for your question.
As you mentioned, sklearn.model_selection.GridSearchCV
expects a scikit-learn "estimator," which is a single-input single-output model. And the wrapper converting a Keras model to a scikit-learn estimator, keras.wrappers.scikit_learn.KerasClassifier
, only supports keras.Sequential
models [1]. Unfortunately, this doesn't support nsl.keras.AdversarialRegularization
models out of the box, because an AdversarialRegularization
model is not a Sequential
model.
One workaround could be that, instead of keras.wrappers.scikit_learn.KerasClassifier
, you use a custom wrapper which take cares of converting the array-style input to dictionary-style. Another workaround might be that you subclass nsl.keras.AdversarialRegularization
and overrides model.fit
(and probably predict
and evaluate
) to convert their x
and y
arguments to something like {'feature': x, 'label': y}
.
Hope this helps.
Closing this issue for now. Feel free to reopen if you have further questions.
Dear, I am trying to implement GridSearchCV on EEG-based BCI dataset. I am unable to implement GridSearchCV may be because of your model needs input in dict and GridSearchCV in not accepting it. Any suggestion?
My Colab notebook is: https://github.com/sagihaider/EEG_Deep/blob/master/main_Single_Trial_Classification_EEGNet_NSL_2A_Grid_Search.ipynb