我是靠谱客的博主 苹果饼干,这篇文章主要介绍ValueError: `steps_per_epoch=None` is only valid for a generator based on the `keras.utils.Sequence`,现在分享给大家,希望可以做个参考。

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:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部