Implementing a multi-input model in Keras, each with a different sample sizes each (different batch sizes each)

僤鯓⒐⒋嵵緔 提交于 2019-12-14 00:17:49

问题


I am currently trying to implement a multi-input model in Keras. The input consists of multiple batches, and each includes different samples, but I get a 'different samples'-error. My implementation looks like this:

The model site looks as follows:

for s in range(NUM_STREAMS):
    inp.append(Input(shape=(16,8)))
...

The site where the error occurs:

history = model.train_on_batch(
                x=[x for x in X_batch],
                y=[y for y in y_batch]
            )

The error I get is:

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)]

The abstract model architecture looks as follow:


回答1:


FYI, when faced with a similar problem, I rewrote my model in tensorflow, as their computational graphs are not constrained to keeping a batch size dimension constant.



来源:https://stackoverflow.com/questions/44101692/implementing-a-multi-input-model-in-keras-each-with-a-different-sample-sizes-ea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!