gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 03:03:35 27 4
gpt4 key购买 nike

我目前正在生成一个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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com