I am using Keras with a Tensorflow backend in Python. To be more precise tensorflow 1.2.1 and its build-in contrib.keras lib.
I want to use the fit_generator
method of a Sequential model object, but I am confused with what I should pass as the method-parameters.
From reading the doc here I got the following information:
- generator : a python training data batch generator; endlessly looping over its training data
- validation_data: -in my case - a python validation data batch generator; the doc doesn't mention endless looping over its validation data
- steps_per_epoch :
number of training batches = uniqueTrainingData / batchSize
- validation steps :
???
; = uniqueValidationData / batch size ??? - use_multiprocessing : boolean; don't pass non picklable arguments ???
- workers : max number of used processes
As indicated above with ??? I don't really know what validation_steps means.
I know the definition of the above linked doc (Number of steps to yield from validation generator at the end of every epoch
) but that only confuses my in the given context. From the doc i know that the validation_data generator has to yield data, label tuples in the form (inputs, targets)
. In contrast to that the above statement indicates that there have to be multiple "steps to yield from validation generator at the end of every epoch" which in this context would mean, that multiple validation batches would be yielded after each training epoch.
Questions about validation_steps
:
- Does it really work that way? If so: Why? I thought that after each epoch one validation batch, which ideally wasn't used before, is used for validation to ensure that the training gets validated without risking to "train" the model to perform better on already used validation sets.
- In context of the previous question: Why is the recommended amount of validation steps
uniqueValidationData / batches
and notuniqueValidationData / epochs
? Isn't it better to have e.g. 100 validation batches for 100 epochs instead of x validation batches where x could be less or more than the specified number of epochs? Alternatively: If you have much less validation batches than number of epoches, is the model trained without validation for the rest of the epochs or do validation sets get reused / reshuffled+reused? - Is it important that the training and validation batches have the same batch size (shared divisor of the dividends trainingDataCount and validationDataCount)?
Additional question about use_multiprocessing
:
- Are numpy arrays picklable or do I have to convert them to multidimensional lists?