使用model.fit_generator时如何应用K折叠交叉验证。我正在向我的网络提供培训和验证数据。我知道使用来自here的sklearn.model_selection.Kfold,但不知道如何申请我的模型。我的模型的一些块是:
train_generator = train_datagen.flow_from_directory('train',
target_size=(50, 50), batch_size=batch_size,
class_mode='binary',color_mode='grayscale')
validation_generator = test_datagen.flow_from_directory('test',
target_size=(50, 50),batch_size=batch_size,
class_mode='binary',color_mode='grayscale')
model.fit_generator(
train_generator,steps_per_epoch=250 ,epochs=40,
validation_data=validation_generator,
validation_steps=21 )