概述
keras 自己写了个generator,然后继承的keras.utils.Sequence,但是在fit_generator()的时候,会报如下错误:
ValueError: `steps_per_epoch=None` is only valid for a generator based on the `keras.utils.Sequence`
就会很懵逼,明明继承了sequence类,然后
isinstance(your_generator,keras.utils.Sequence)
也显示true。
结果查了下,是因为代码块有的地方是直接import keras,而有的地方是import tensorflow.keras。这里的import需要保证统一。
感谢:https://github.com/keras-team/keras/issues/10855
For me it turned out that I used tensorflow import (import tensorflow.keras.utils.Sequence as sequence) for the sequence generator, but for the model I was training I used the keras import (from keras.layers import..... and from keras.models import....etc.)
changing to tensorflow.keras.layers, tensorflow.keras.models....etc worked for me.
最后
以上就是苹果饼干为你收集整理的ValueError: `steps_per_epoch=None` is only valid for a generator based on the `keras.utils.Sequence`的全部内容,希望文章能够帮你解决ValueError: `steps_per_epoch=None` is only valid for a generator based on the `keras.utils.Sequence`所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复