在Keras中实现多输入模型,每个模型具有不同的样本大小(每个批次具有不同的大小)

Dav*_*eAl 5 python batch-processing deep-learning keras tensorflow

我目前正在尝试在Keras中实现多输入模型。输入包含多个批次,每个批次包含不同的样本,但是出现“不同样本”错误。我的实现如下所示:

该模型站点如下所示:

for s in range(NUM_STREAMS):
    inp.append(Input(shape=(16,8)))
...
Run Code Online (Sandbox Code Playgroud)

发生错误的站点:

history = model.train_on_batch(
                x=[x for x in X_batch],
                y=[y for y in y_batch]
            )
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

ValueError: All input arrays (x) should have the same number of
samples. Got array shapes: [(6, 16, 8), (7, 16, 8), (6, 16, 8), (6, 16, 8)]
Run Code Online (Sandbox Code Playgroud)

抽象模型架构如下所示:

多输入多输出

tho*_*444 3

仅供参考,当遇到类似的问题时,我在张量流中重写了我的模型,因为它们的计算图不限于保持批量大小尺寸恒定。