How to import KerasClassifier for use with Gridsearch?
The following
from tensorflow.keras.layers.wrappers.scikit_learn import KerasClassifier
Used to work, but now returns:
ModuleNotFoundError: No module named 'tensorflow.keras.wrappers'
I understand there have been several changes to Tensorflow and Keras. I would prefer not to just install an older version, so I'm working to figure out how to use this going foward.
Reading elsewhere, it sounds like this may have been deprecated and replaced by SciKeras, but it sounds like that may also require a lot of other changes to the code. I have many instances of doing fits and using the history.
Is making that switch the best way given a limited timeframe? Should I just go to an older version?
Currently running tf version 2.13.0 and keras version 2.13.1 and I've recently updated both so don't think it's a version mismatch item. It may be I just need to take both back to 2.12.
The proposed changes in adriangb.com/scikeras worked for me. I could use GridSearch
. Also had to first install scikeras
:
pip install scikeras
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With