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