tensorflow - 拟合生成器函数中的数据增强误差

标签 tensorflow machine-learning keras data-augmentation

我正在尝试训练用于面部表情检测的 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,弄乱了您输入的形状。

也许这个问题可以通过 numpyreshape 来解决。

关于tensorflow - 拟合生成器函数中的数据增强误差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55853380/

相关文章:

c# - Accord.Net 获取SVM模型的方程

machine-learning - 优化网络爬虫的关键字权重

machine-learning - 使用 libsvm 进行分类训练

python - 减少 tensorflow 中的矩阵数组

python - Keras 访问自定义损失函数中的各个值

python - 将 KERAS 张量转换为 K.tf.int32

python - 为什么 Keras 不需要自定义损失函数的梯度?

python - 如何在Keras中为 'Tensor'对象赋值?

python - Keras 上的损失层使用两个输入层和 numpy 运算

python - 为什么即使我使用 sparse_categorical_crossentrpy 也会得到 "Received a label value of 6 which is outside the valid range of [0, 1)"?