<p dir="auto">Hi,<br>
here is a bug in this example here:<br>
<a href="https://github.com/keras-team/keras/blob/master/examples/cifar10_resnet.py#L423">https://github.com/keras-team/keras/blob/master/examples/cifar10_resnet.py#L423</a></p>
<p dir="auto">The Exception is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ValueError: `steps_per_epoch=None` is only valid for a generator based on the 
`keras.utils.Sequence` class. Please specify `steps_per_epoch` or use the 
`keras.utils.Sequence` class."><pre class="notranslate"><code class="notranslate">ValueError: `steps_per_epoch=None` is only valid for a generator based on the 
`keras.utils.Sequence` class. Please specify `steps_per_epoch` or use the 
`keras.utils.Sequence` class.
</code></pre></div>
<p dir="auto"><code class="notranslate">model.fit_generator</code> whould specify <code class="notranslate">steps_per_epoch</code>.</p>
<p dir="auto">By example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size),
                        steps_per_epoch=int(50000/batch_size),
                        validation_data=(x_test, y_test),
                        epochs=epochs, verbose=1, workers=4,
                        callbacks=callbacks)"><pre class="notranslate"><code class="notranslate">    model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size),
                        steps_per_epoch=int(50000/batch_size),
                        validation_data=(x_test, y_test),
                        epochs=epochs, verbose=1, workers=4,
                        callbacks=callbacks)
</code></pre></div>
<p dir="auto">Tensorflow 1.11.0<br>
Keras 2.2.4<br>
Keras-Preprocessing 1.0.5<br>
Ubuntu 16.04<br>
Python 2.7.12</p>
<p dir="auto">Example code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from keras import models, layers
from keras_preprocessing.image import ImageDataGenerator
from keras_applications.imagenet_utils import preprocess_input

train_dir = '/tmp/workspace/Pet_Dataset/train/'
height, width, channels = (128, 128, 3)
batch_size=32

train_datagen = ImageDataGenerator(rescale=1.0/255)
train_generator = train_datagen.flow_from_directory(
              train_dir, target_size=(height, width),
              batch_size=batch_size, class_mode='categorical')

network = models.Sequential()
network.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(height, width, channels)))
network.add(layers.MaxPooling2D((2, 2)))
network.add(layers.Conv2D(64, (3, 3), activation='relu'))
network.add(layers.MaxPooling2D((2, 2)))
network.add(layers.Conv2D(128, (3, 3), activation='relu'))
network.add(layers.MaxPooling2D((2, 2)))
network.add(layers.Conv2D(256, (3, 3), activation='relu'))
network.add(layers.GlobalAveragePooling2D())
network.add(layers.Dense(train_generator.num_classes, activation='softmax'))

network.compile(optimizer='RMSProp',
                   loss='categorical_crossentropy',
                   metrics=['accuracy'])
network.summary()

history = network.fit_generator(train_generator, epochs=10) "><pre class="notranslate"><code class="notranslate">from keras import models, layers
from keras_preprocessing.image import ImageDataGenerator
from keras_applications.imagenet_utils import preprocess_input

train_dir = '/tmp/workspace/Pet_Dataset/train/'
height, width, channels = (128, 128, 3)
batch_size=32

train_datagen = ImageDataGenerator(rescale=1.0/255)
train_generator = train_datagen.flow_from_directory(
              train_dir, target_size=(height, width),
              batch_size=batch_size, class_mode='categorical')

network = models.Sequential()
network.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(height, width, channels)))
network.add(layers.MaxPooling2D((2, 2)))
network.add(layers.Conv2D(64, (3, 3), activation='relu'))
network.add(layers.MaxPooling2D((2, 2)))
network.add(layers.Conv2D(128, (3, 3), activation='relu'))
network.add(layers.MaxPooling2D((2, 2)))
network.add(layers.Conv2D(256, (3, 3), activation='relu'))
network.add(layers.GlobalAveragePooling2D())
network.add(layers.Dense(train_generator.num_classes, activation='softmax'))

network.compile(optimizer='RMSProp',
                   loss='categorical_crossentropy',
                   metrics=['accuracy'])
network.summary()

history = network.fit_generator(train_generator, epochs=10) 
</code></pre></div>
<p dir="auto">breaks with Tensorflow 1.11.0 with <code class="notranslate">ValueError: steps_per_epoch=None is only valid for a generator based on the keras.utils.Sequence class. Please specify steps_per_epoch or use the keras.utils.Sequence class.</code>.</p>
<p dir="auto">Tensorflow 1.10.0 and below works.</p>
<p dir="auto">Furthermore, providing steps_per_epoch and applying multiprocessing with workers &gt; 1:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="history = network.fit_generator(train_generator, epochs=10, 
    steps_per_epoch=train_generator.n/batch_size,
    use_multiprocessing=True, workers=2)"><pre class="notranslate"><code class="notranslate">history = network.fit_generator(train_generator, epochs=10, 
    steps_per_epoch=train_generator.n/batch_size,
    use_multiprocessing=True, workers=2)
</code></pre></div>
<p dir="auto">causes a UserWarning about multiple workers duplicate data.</p>
<p dir="auto">I think this is caused by wrong inheritance of ImageDataGenerator.</p>
<p dir="auto">When printing the exact class that is used in <code class="notranslate">keras_preprocessing/image.py</code>, I get <code class="notranslate">&lt;class 'tensorflow.python.keras.utils.data_utils.Sequence'&gt;</code>.</p>
<p dir="auto">But <code class="notranslate">fit_generator()</code> checks if the generator is a subclass of <code class="notranslate">&lt;class 'keras.utils.data_utils.Sequence'&gt;</code>, so it seems to assume that the ImageDataGenerator instance is not of type Sequence, causing above problems.</p>