keras在每N个训练时期之后运行验证

时间:2018-04-24 11:12:04

标签: validation tensorflow deep-learning keras

我正在使用以下功能来训练/验证我的模型:

model.fit_generator(
    train_generator,
    steps_per_epoch=nb_train_samples // batch_size,
    epochs=epochs,
    validation_data=validation_generator,
    validation_steps=nb_validation_samples // batch_size,
    verbose=2, workers=12)

上述功能在每个时期运行验证。我的验证数据非常大,所以我希望每隔N个时期运行一次。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

看起来keras已使用新的输入参数validation_freq更新了fit / fit_generator,该参数可用于设置验证数据的评估频率。根据文档(从2.2.4版开始):

fit(x=None, y=None, batch_size=None, epochs=1, verbose=1, callbacks=None, validation_split=0.0, validation_data=None, shuffle=True, class_weight=None, sample_weight=None, initial_epoch=0, steps_per_epoch=None, validation_steps=None, validation_freq=1)
fit_generator(generator, steps_per_epoch=None, epochs=1, verbose=1, callbacks=None, validation_data=None, validation_steps=None, validation_freq=1, class_weight=None, max_queue_size=10, workers=1, use_multiprocessing=False, shuffle=True, initial_epoch=0)