Generator “TypeError: 'generator' object is not an iterator”

前端 未结 3 591
-上瘾入骨i
-上瘾入骨i 2020-12-18 11:03

Due to the limitation of RAM memory, I followed these instructions and built a generator that draw small batch and pass them in the fit_generator of Keras. But Keras can\'t

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-18 11:48

    I received the same error saying my generator class which inherited from keras.utils.Sequence object is not an iterator.

    Neither adding the __next__ method nor changing between keras.utils.Sequence and tf.keras.utils.Sequence helped.

    For me, my __getitem__ class was not correctly implemented. While trying to use all the data, the last batch was a partial batch which I was not handling correctly. When I handled this correctly, the object is not an iterator error went away. Thus, I suggest you carefully inspect your __getitem__() implementation and consider it for all index values passed to __getitem__().

提交回复
热议问题