From 64b332b0cc5418e1eea6a66d786bf44e7de4d8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A9o=20Bouvard?= Date: Sun, 15 Mar 2020 01:27:24 +0100 Subject: [PATCH 1/2] Replace fit_generator by fit Function fit_generator is deprecated, but is still used as an example of how to use ImageDataGenerator. This patch fixes the two examples where fit_generator is used. --- tensorflow/python/keras/preprocessing/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/keras/preprocessing/image.py b/tensorflow/python/keras/preprocessing/image.py index 0b7e2967dea..b3dbe2984a1 100644 --- a/tensorflow/python/keras/preprocessing/image.py +++ b/tensorflow/python/keras/preprocessing/image.py @@ -452,7 +452,7 @@ class ImageDataGenerator(image.ImageDataGenerator): # (std, mean, and principal components if ZCA whitening is applied) datagen.fit(x_train) # fits the model on batches with real-time data augmentation: - model.fit_generator(datagen.flow(x_train, y_train, batch_size=32), + model.fit(datagen.flow(x_train, y_train, batch_size=32), steps_per_epoch=len(x_train) / 32, epochs=epochs) # here's a more "manual" example for e in range(epochs): @@ -486,7 +486,7 @@ class ImageDataGenerator(image.ImageDataGenerator): target_size=(150, 150), batch_size=32, class_mode='binary') - model.fit_generator( + model.fit( train_generator, steps_per_epoch=2000, epochs=50, From 55fa8bafc8845a9b3dcbead604a3cb5ab0a0aaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A9o=20Bouvard?= Date: Thu, 26 Mar 2020 15:25:42 +0100 Subject: [PATCH 2/2] Fix indentation --- tensorflow/python/keras/preprocessing/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/keras/preprocessing/image.py b/tensorflow/python/keras/preprocessing/image.py index b3dbe2984a1..d58a4fcd2b2 100644 --- a/tensorflow/python/keras/preprocessing/image.py +++ b/tensorflow/python/keras/preprocessing/image.py @@ -453,7 +453,7 @@ class ImageDataGenerator(image.ImageDataGenerator): datagen.fit(x_train) # fits the model on batches with real-time data augmentation: model.fit(datagen.flow(x_train, y_train, batch_size=32), - steps_per_epoch=len(x_train) / 32, epochs=epochs) + steps_per_epoch=len(x_train) / 32, epochs=epochs) # here's a more "manual" example for e in range(epochs): print('Epoch', e)