Keras function --mode.fit_generator ()

1 model.fit_generator(self,generator, steps_per_epoch, epochs=1, verbose=1, callbacks=None, validation_data=None, validation_steps=None, class_weight=None, max_q_size=10, workers=1, pickle_safe=False, initial_epoch=0)

  Using Python generator, generated by one batch of data and training. Generating parallel execution with the model to improve efficiency. For example, this function allows us to enhance the real-time data on the CPU, while the model train on the GPU

  Function parameters are:

  • generator: a function generator, the output should be generated:

    • Shaped like a (inputs, targets) of the tuple

    • Shaped like a (inputs, targets, sample_weight) of the tuple. All return value should contain the same number of samples. Builder infinite loop on the data set. After several samples of each epoch to the model reached sameples_per_epochwhen a record epoch ended.

  • steps_per_epoch: integer, when the return to the generator steps_per_epochwhen a time count data epoch ends, execution of the next epoch. The recommended value样本总量除以train_flow的batch_size。如果未指定(None),则fit_generator的steps_per_epoch等于train_flow的batch_size。

  • epochs: integer data several rounds of iterations.

  • verbose: log shows, not in the standard output stream 0 is output log information, a recording progress bar output, two for each epoch output a row.

  • validation_data: have one of three forms

    • Generating a validation set generator

    • Shaped like a (inputs, targets) of the tuple

    • Shaped like a (inputs, targets, sample_weights) the tuple

  • validation_steps: when the generator is validation_data, this parameter specifies the authentication return generator set times.

  • class_weight: prescribed weight category right dictionary, the category is mapped to weight commonly used in the processing of samples imbalance.

  • sample_weight: numpy array weights for adjusting the loss function in training (for training only). 1D may be a transfer matrix with a vector length of the sample weight and the like for samples 1 to 1, or in the face of time series data is transmitted in the form of a (samples, sequence_length) to each time step of the sample assigned different weights. In this case make sure to add when compiling the model sample_weight_mode='temporal'.

  • workers: maximum number of processes

  • max_q_size: generating a maximum capacity of the queue

  • pickle_safe: If true, the process-based threads. Since the multi-process implementation-dependent, can not pass non picklable (pickle can not be serialized) parameters to the generator, since the child can not easily pass them to the process.

  • initial_epoch:, useful to start training from the epoch of the parameters specified in the training before continuing.

  Function returns an HistoryObject

Guess you like

Origin www.cnblogs.com/Johnny-z6951/p/11271339.html