I am using Keras to create a CNN model, and I would to use K-fold cross-validation to train the dataset.

The dataset contains images and I am using flow_from_directory function.

Do you have any idea how to use K-fold cross-validation in Keras to create a CNN model??

  • $\begingroup$ Very expensive, this is why we use a validation set. $\endgroup$ Sep 24 '18 at 6:33
  • $\begingroup$ Do you mean Cross-validation method is very expensive? $\endgroup$
    – N.IT
    Sep 24 '18 at 12:09
  • $\begingroup$ Yes cross validation is considered expensive for dnn , because you have to do the training , testing k times $\endgroup$ Sep 24 '18 at 14:52
  • 1
    $\begingroup$ I want to do cross validation, even if it is expensive $\endgroup$
    – N.IT
    Oct 2 '18 at 5:02

It is very common to use sklearn for cross validation.

The most known methods are KFold and cross_val_score imported from sklearn.model_selection.

You can then use tf.keras.wrappers.scikit_learn.KerasClassifier to implement the scikit-learn classifier with Keras model.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.