我是靠谱客的博主 苹果饼干,最近开发中收集的这篇文章主要介绍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: `steps_per_epoch=None` is only valid for a generator based on the `keras.utils.Sequence`所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部