ShannonAI / service-streamer

Boosting your Web Services of Deep Learning Applications.
Apache License 2.0
1.23k stars 186 forks source link

多输入报错 #17

Closed saxh closed 4 years ago

saxh commented 5 years ago

我用keras 做多输入预测的时候,好像数据组成batch的时候会有问题。单条预测没问题,做压测的时候就报错了。

这是keras的输入和输出,有两个输入,不知道你们考虑过没有 model = Model([x1_in, x2_in], p)

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 2 array(s), but instead got the following list of 3 arrays: [array([[0], [2], [3], [4], [5], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]]), array([[0], ...

pku-wuwei commented 5 years ago

可能是传给Streamer的prediction_function输入输出格式不符合预期,prediction_function需要封装成List[Instance]做输入,List[Output]做输出。具体可参考example/bert_model.py的TextInfillingModel。

saxh commented 5 years ago

可能是传给Streamer的prediction_function输入输出格式不符合预期,prediction_function需要封装成List[Instance]做输入,List[Output]做输出。具体可参考example/bert_model.py的TextInfillingModel。

的确是,我这边传入的值需要是 [List[input1],List[input2]],咋改一下呢

Meteorix commented 5 years ago

@saxh 你需要把input1和input2重新组装一下,变成List[input],然后list长度等于batch长度,比如:

[[1,2,3], [2,3,4]]
# 改成
[[(1,2), (2,3), (3,4)]