Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用paddle_infer.py预测naml模型失败 #675

Closed
shentanyue opened this issue Jan 12, 2022 · 2 comments
Closed

使用paddle_infer.py预测naml模型失败 #675

shentanyue opened this issue Jan 12, 2022 · 2 comments

Comments

@shentanyue
Copy link

将naml模型导出为Paddle Inference模型后,使用paddle_infer.py脚本进行预测,但不能正确运行。
这是我的执行命令:
python3 ../../../tools/paddle_infer.py --model_file=PaddleRec_model/naml/model.pdmodel --params_file=PaddleRec_model/naml/model.pdiparams --use_gpu=False --data_dir=data/sample_data/train/ --reader_file=NAMLDataReader.py --batchsize=1 --benchmark=False

但由于NAMLDataReader.py里缺少config的读取,因此我在里面也加了下列代码。
config = load_yaml("/Work/PaddleRec/models/rank/naml/config.yaml")

但还是会报输入shape不匹配的问题:
InvalidArgumentError: The shape of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1, 10], input[1]'s shape = [1, 5, 10].
[Hint: Expected inputs_dims[i].size() == out_dims.size(), but received inputs_dims[i].size():3 != out_dims.size():2.] (at /paddle/paddle/fluid/operators/concat_op.h:40)
[operator < concat > error]

有什么办法可以让我使用Paddle Inference来推理naml吗?

@yinhaofeng
Copy link
Contributor

这里导出为Paddle Inference的时候,你需要注意模型的输入和输出分别指定在哪里,我们会根据您指定的输入和输出自行裁剪组网。这可能导致有时reader传入的值和需要的输入值并非完全匹配,您可能需要手动调整输入。比如在作为示例的wide&deep模型中,预测的时候并不需要label,那么在reader传入数据的时候就使用了self.inference参数,输出将label去掉的数据。您可以参照这个写法调整输入的shape,使之与需求的shape相符。

@shentanyue
Copy link
Author

thanks,已搞定~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants