Reputation: 1609
I'm using tensorflow.keras.utils.Sequence to model.fit_generator.
I'm retrieving data and shuffling one batch at a time instead of loading everything into ram.
In my __init__
, I have self.datagen = ImageDataGenerator(width_shift_range=0.2, height_shift_range=0.2, zoom_range=0.2)
.
Then in my __getitem__
, I have:
self.datagen.fit(x_batch)
x_batch = next(self.datagen.flow(x_batch, batch_size=len(x_batch)))
Is this the best way to transform everything at once?
Upvotes: 1
Views: 106
Reputation: 2522
You could just call fit_generator
instead of fit
and next
. In this way, you wouldn't need to iterate over all your data. For more information about fit_generator
take a look into keras help
Upvotes: 1