title: Use a generator for Keras model.fit_generator
body: <p>I originally tried to use <code>generator</code> syntax when writing a custom generator for training a Keras model. So I <code>yield</code>ed from <code>__next__</code>. However, when I would try to train my mode with <code>model.fit_generator</code> I would get an error that my generator was not an iterator. The fix was to change <code>yield</code> to <code>return</code> which also necessitated rejiggering the logic of <code>__next__</code> to track state. It's quite cumbersome compared to letting <code>yield</code> do the work for me.</p>
  
  <p>Is there a way I can make this work with <code>yield</code>? I will need to write several more iterators that will have to have very clunky logic if I have to use a <code>return</code> statement.</p>