Reputation: 2164
I've noticed that with fit_generator
, the steps_per_epoch
parameter is usually assigned total_samples//batch_size
, where one can create a generator/use ImageDataGenerator
and pass it as an argument to fit_generator
.
However I am using the Sequence
class (keras.utils.Sequence()
) to create my generator and passing steps_per_epoch
an integer less than total_samples//batch_size
.
What I would like to know is would the generation of data start in the generator start from the beginning once each epoch is completed?
For example, I have 3200 samples in my training set and I use a batch size of 32. So ideally for one complete epoch I should set steps_per_epoch
to 100. However what would happen if I set my steps_per_epoch
to 50? Once the first epoch is completed would data point number 1601 (32*50) be generated or would it start from the beginning (data point number 1) ?
Upvotes: 3
Views: 783
Reputation: 56357
When using Sequence
, you do not need to pass steps_per_epoch
, as this information can be inferred from the __len__
method of your Sequence.
If you pass steps_per_epoch
while using Sequence
, this will override any use of the __len__
method and it will effectively only use steps_per_epoch
samples from your sequence (from 0 to steps_per_epoch - 1
), and it will reset back to zero at the end of the epoch. You can check this behavior in the keras source code.
Upvotes: 4