• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to use RandomizedSearchCV of Scikit-Learn with ImageDataGenerator of Tensorflow

Resolved: How to use RandomizedSearchCV of Scikit-Learn with ImageDataGenerator of Tensorflow

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I’m trying to implement a RandomizedSearchCV using the ImageDataGenerators.
Here an example of the generator used for the train set:
I’ve done the same for the validation_generator and finally the model has been fitted as:
I would like to apply a grid search (using sklearn RandomizedSearchCV) to optimize my model, for that reason I used SciKeras:
where keras_reg is the KerasClassifier which wraps the model for sklearn and param_distribs is the dictionary with the hyperparameters values.
Finally I fitted the RandomizedSearchCV object as follows:
I have the following error:
Do you know how to integrate RandomizedSearchCV and ImageDataGenerator objects?

Answer:

I don’t recommend the below solution and approch. I highly recommend using KerasTuner but If you want to input keras.preprocessing.image.DirectoryIterator like your train_generator to RandomizedSearchCV you need to extract X and Y from DirectoryIterator then input them to RandomizedSearchCV like below:

If you have better answer, please add a comment about this, thank you!

hyperparameters keras python scikit-learn tensorflow
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Resolved: In a Pinescript v5 Strategy why is my bool not working?

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.