title: Keras model.fit_generator raises Stopiteration error
body: <p>I am trying to run a port of the SSD on a Win10 system from the ssd300_training.ipynb code in  this github repo <a href="https://github.com/pierluigiferrari/ssd_keras" rel="nofollow noreferrer">https://github.com/pierluigiferrari/ssd_keras</a> .
  I am getting a "StopIteration" error when training the model and the solutions out there, with my little research, suggest adding a while True block in the data generator function. However, I am not as proficient enough to do that with the code as it wasn't written like a function format.
  Here's the data generator code:</p>
  
  <pre><code># 6: Create the generator handles that will be passed to Keras' `fit_generator()` function.
  train_generator = train_dataset.generate(batch_size=batch_size,
                                       shuffle=True,
                                       transformations=[ssd_data_augmentation],
                                       label_encoder=ssd_input_encoder,
                                       returns={'processed_images',
                                                'encoded_labels'},
                                       keep_images_without_gt=False)
  
  val_generator = val_dataset.generate(batch_size=batch_size,
                                   shuffle=False,
                                   transformations=[convert_to_3_channels,
                                                    resize],
                                   label_encoder=ssd_input_encoder,
                                   returns={'processed_images',
                                            'encoded_labels'},
                                   keep_images_without_gt=False)  
  </code></pre>
  
  <p>Please how can I add a while True: loop to this so it can stop giving the StopIteration error. Here's the training code and the error it gives:</p>
  
  <pre><code>initial_epoch   = 0
  final_epoch     = 50
  steps_per_epoch = 10
  
  
  
  history = model.fit_generator(generator=train_generator,
                            steps_per_epoch=steps_per_epoch,
                            epochs=final_epoch,
                            callbacks=callbacks,
                            validation_data=val_generator,
                            validation_steps=ceil(val_dataset_size/batch_size),
                            initial_epoch=initial_epoch
                           )
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>    Epoch 1/50
   9/10 [==========================&gt;...] - ETA: 24s - loss: 3.45 - ETA: 13s - loss: 3.45 - ETA: 9s - loss: 3.4506 - ETA: 6s - loss: 3.450 - ETA: 5s - loss: 3.450 - ETA: 3s - loss: 3.450 - ETA: 2s - loss: 3.450 - ETA: 1s - loss: 3.450 - ETA: 0s - loss: 3.4504
  ---------------------------------------------------------------------------
  StopIteration                             Traceback (most recent call last)
  &lt;ipython-input-16-484d98ebb6b5&gt; in &lt;module&gt;()
       11                               #callbacks=callbacks,
       12                               validation_data=val_generator,
  ---&gt; 13                               validation_steps=ceil(val_dataset_size/batch_size),
       14                               #initial_epoch=initial_epoch
       15                              )
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
       89                 warnings.warn('Update your `' + object_name +
       90                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
  ---&gt; 91             return func(*args, **kwargs)
       92         wrapper._original_function = func
       93         return wrapper
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
     1413             use_multiprocessing=use_multiprocessing,
     1414             shuffle=shuffle,
  -&gt; 1415             initial_epoch=initial_epoch)
     1416 
     1417     @interfaces.legacy_generator_methods_support
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\engine\training_generator.py in fit_generator(model, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
      228                             val_enqueuer_gen,
      229                             validation_steps,
  --&gt; 230                             workers=0)
      231                     else:
      232                         # No need for try/except because
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
       89                 warnings.warn('Update your `' + object_name +
       90                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
  ---&gt; 91             return func(*args, **kwargs)
       92         wrapper._original_function = func
       93         return wrapper
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\engine\training.py in evaluate_generator(self, generator, steps, max_queue_size, workers, use_multiprocessing, verbose)
     1467             workers=workers,
     1468             use_multiprocessing=use_multiprocessing,
  -&gt; 1469             verbose=verbose)
     1470 
     1471     @interfaces.legacy_generator_methods_support
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\engine\training_generator.py in evaluate_generator(model, generator, steps, max_queue_size, workers, use_multiprocessing, verbose)
      325 
      326         while steps_done &lt; steps:
  --&gt; 327             generator_output = next(output_generator)
      328             if not hasattr(generator_output, '__len__'):
      329                 raise ValueError('Output of generator should be a tuple '
  
  c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\utils\data_utils.py in get(self)
      783                 all_finished = all([not thread.is_alive() for thread in self._threads])
      784                 if all_finished and self.queue.empty():
  --&gt; 785                     raise StopIteration()
      786                 else:
      787                     time.sleep(self.wait_time)
  
  StopIteration: 
  </code></pre>
  
  <p>Thanks for your help</p>