Questions of predict_generator params based on Keras2

Recently, I review the code of dogcat classification .

I found the predict_generator api changed.

As the official documents says

predict_generator(self, generator, steps, max_queue_size=10, workers=1, use_multiprocessing=False, verbose=0)
generator: generator yielding batches of input samples.
steps: Total number of steps (batches of samples) to yield from generator before stopping.

So I changed the code like this

print ("Train Batches:")
train_generator = gen.flow_from_directory(train_path, model.input_shape[1:3], batch_size=100, shuffle=False)
print ("\nValid Batches:")
valid_generator = gen.flow_from_directory(valid_path, model.input_shape[1:3], batch_size=100, shuffle=False)
print ("\nTest Batches:")
test_generator = test_gen.flow_from_directory(test_path, model.input_shape[1:3], batch_size=100, shuffle=False, class_mode=None)

%%time
train_bn = model.predict_generator(train_generator, steps=int(train_generator.samples/train_generator.batch_size))

But the raied error, I dont understand why.Anyone can cover it?

Exception in thread Thread-121:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/keras/utils/data_utils.py", line 568, in data_generator_task
    generator_output = next(self._generator)
  File "/usr/local/lib/python3.5/dist-packages/keras/preprocessing/image.py", line 737, in __next__
    return self.next(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/keras/preprocessing/image.py", line 1026, in next
    batch_x = np.zeros((current_batch_size,) + self.image_shape, dtype=K.floatx())
TypeError: 'NoneType' object cannot be interpreted as an integer


StopIterationTraceback (most recent call last)
<timed exec> in <module>()

/usr/local/lib/python3.5/dist-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
     85                 warnings.warn('Update your `' + object_name +
     86                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 87             return func(*args, **kwargs)
     88         wrapper._original_function = func
     89         return wrapper

/usr/local/lib/python3.5/dist-packages/keras/engine/training.py in predict_generator(self, generator, steps, max_queue_size, workers, use_multiprocessing, verbose)
   2270 
   2271             while steps_done < steps:
-> 2272                 generator_output = next(output_generator)
   2273                 if isinstance(generator_output, tuple):
   2274                     # Compatibility with the generators

StopIteration: 

Predict_generator, fit_generator are used when images are read and iterated from directory. For your case use predict e.g model.predict to predict images instead of using a generator. Generator helps reading images from directory.