python - keras fit_generator 用于多个批处理和多个输入

标签 python numpy keras

我目前正在生成一个data_generate(batch_size),它接受 batch_size 作为参数。

我的网络是多输入网络,有 33 个形状为 (45,8,3) 的输入

如果批量大小 = 1 ,那么我可以轻松地将输入数据生成为 [33 个输入],但是当批量大小变为 > 1 时,我不确定应该如何处理格式化我的输入数据。

这样做[[33输入],[33输入],[33输入],[33输入],..,[33输入]]似乎不起作用,正如keras所期望的那样列表中的第一个条目是 numpy.ndarray,在本例中是 numpy ndarray 的列表。

我可以给它一个形状为 (33,45,8,3) 的 numpy 数组列表,例如 [(33,45,8,3),(33,45,8,3) ,(33,45,8,3),.....,(33,45,8,3)]

但是当我用 2 进行测试时,这会导致此错误:

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 33 arrays but instead got the following list of 2 arrays: [array([[[[ 3.,  4.,  4.],

那么所需的输入格式是什么?

最佳答案

我相信您的输入所需的格式是:

形状为 (batch_size, 45, 8, 3) 的 33 个 numpy 数组的列表,第一个维度将是批处理。

关于python - keras fit_generator 用于多个批处理和多个输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43615859/

相关文章:

python - 在附加维度上重复 keras( tensorflow )模型

python - Keras 只训练特定的输出

python - 使用数据集的一部分来训练我的模型有意义吗?

python - 在其他多项式上评估 numpy 多项式

python - keras 从 yolov2 加载自定义模型时出现问题

python - numpy代码中的溢出错误

python - 对 numpy 数组的两列求和并将其添加为数组的第三列

python - 等待用户操作继续执行代码

python - 如何从 python 循环中获取特定术语

python - 为什么 python 在下载包时给出 fatal error ?