我正在尝试训练用于面部表情检测的 cnn 模型并减少输入类的不平衡,我使用 keras 的 ImageDataGenerator 扩大我的数据集。
这是我的代码:
xs >> input
ys >> output
data_gen = ImageDataGenerator(horizontal_flip =True, featurewise_center=True, featurewise_std_normalization=True)
data_gen.fit(xs)
history = self.model.fit_generator((data_gen.flow(xs,ys batch_size=self.batch_size)), steps_per_epoch=len(xs) / self.batch_size, epochs=epochs_num)
我生成了很多图像并将其输入模型中进行训练,但它给了我这个错误: 无法将输入数组从形状 (28709,128) 广播到形状 (28709)
如何确定此错误的原因?
最佳答案
It would be nice if you would share a running example of your code, so that it is possible to reproduce the error.
我的第一个猜测是某个变量(可能是您的 batch_size
),即 128,弄乱了您输入的形状。
也许这个问题可以通过 numpy
的 reshape
来解决。
关于tensorflow - 拟合生成器函数中的数据增强误差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55853380/