The generator is run in parallel to the model, for efficiency. For instance, this allows you to do real-time data augmentation on images on CPU in parallel to training your model on GPU.

fit_generator(object, generator, steps_per_epoch, epochs = 1, verbose = 1,
  callbacks = NULL, validation_data = NULL, validation_steps = NULL,
  class_weight = NULL, max_queue_size = 10, initial_epoch = 0)

Arguments

object

Keras model object

generator

A generator (e.g. like the one provided by flow_images_from_directory() or a custom R generator function).

The output of the generator must be a list of one of these forms:

 - (inputs, targets)
 - (inputs, targets, sample_weights)

All arrays should contain the same number of samples. The generator is expected to loop over its data indefinitely. An epoch finishes when steps_per_epoch batches have been seen by the model.

steps_per_epoch

Total number of steps (batches of samples) to yield from generator before declaring one epoch finished and starting the next epoch. It should typically be equal to the number of unique samples if your dataset divided by the batch size.

epochs

integer, total number of iterations on the data.

verbose

verbosity mode, 0, 1, or 2.

callbacks

list of callbacks to be called during training.

validation_data

this can be either:

  • a generator for the validation data

  • a list (inputs, targets)

  • a list (inputs, targets, sample_weights).

validation_steps

Only relevant if validation_data is a generator. Total number of steps (batches of samples) to yield from generator before stopping.

class_weight

dictionary mapping class indices to a weight for the class.

max_queue_size

maximum size for the generator queue

initial_epoch

epoch at which to start training (useful for resuming a previous training run)

Value

Training history object (invisibly)

See also

Other model functions: compile, evaluate_generator, evaluate, fit, get_config, get_layer, keras_model_sequential, keras_model, pop_layer, predict.keras.engine.training.Model, predict_generator, predict_on_batch, predict_proba, summary.keras.engine.training.Model, train_on_batch