Python 检查模型输入时出错:找到:<;keras.preprocessing.image.DirectoryIterator。。。对象>;在克拉斯

Python 检查模型输入时出错:找到:<;keras.preprocessing.image.DirectoryIterator。。。对象>;在克拉斯,python,keras,Python,Keras,我在迭代器中有成批的数据,在这里,使用本地Keras,没有什么特别之处: batches=gen.flow\u from\u目录(路径,target\u size=(224224),class\u mode=class\u mode,shuffle=shuffle,batch\u size=batch\u size) 看起来不错: 打印批次: 位于0x7f107c004210的keras.preprocessing.image.DirectoryIterator对象\ 但是现在我已经编译好了,我

我在迭代器中有成批的数据,在这里,使用本地Keras,没有什么特别之处:

batches=gen.flow\u from\u目录(路径,target\u size=(224224),class\u mode=class\u mode,shuffle=shuffle,batch\u size=batch\u size)

看起来不错:

打印批次:

位于0x7f107c004210的keras.preprocessing.image.DirectoryIterator对象\

但是现在我已经编译好了,我已经准备好了

model.compile(优化器=Adam(1e-5),loss='classifical\u crossentropy',
度量=['accurity'])

model.fit(批次、val\u批次、nb\u历元=1)

但我一直得到:

异常:检查模型输入时出错:数据应为Numpy数组,或Numpy数组的列表/目录。找到:…


不Keras不喜欢我用迭代器?为什么我不能使用迭代器?我想这就是重点——不要耗尽所有内存,而是使用某种批迭代器

fit
方法期望其输入为Numpy数组或Numpy数组列表。您应该改为使用,它将生成器作为其参数

model.fit_generator(generator=batches, 
                    validation_data=val_batches, 
                    nb_epoch=1)

您需要使用fit_生成器,而不是fit。