keras thread safe generator for model.fit_generator with Python 3.6.x
In Python 3, you should use next(self.it)
instead of self.it.next()
.
You could also try using Keras Sequences, it seems safer, since it's indexed to preserve the correct order of data when multiprocessing.
Finally, it seems that workers
affect only the generator itself, not the model. In my tests (I'm not good in threading either...) the only difference I could see with more workers was a bigger queue of preloaded data waiting for their turn into the model.