首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在字符串输入上使用onnx运行时进行预测

在字符串输入上使用onnx运行时进行预测
EN

Stack Overflow用户
提问于 2019-06-04 00:22:45
回答 1查看 0关注 0票数 0

我正在尝试对已打包为ONNX的sklearn管道中的文本进行预测。我能够写出并读入模型,但是当我进行预测时,我得到错误:“方法运行失败,原因是:[ONNXRuntimeError]:2:INVALID_ARGUMENT:缺少必需的输入:float_input”。有谁知道如何从文本上的sklearn管道进行预测?

我已经按照本教程http://onnx.ai/sklearn-onnx/auto_examples/plot_tfidfvectorizer.html#sphx-glr-download-auto-examples-plot-tfidfvectorizer-py进行了预测。

代码语言:javascript
复制
'''
#convert pipeline into onnx
model_onnx = convert_sklearn(pipeline, "tfidf",
                             initial_types=[("str_input", StringTensorType([1, 2000]))])

with open("pipeline_emails.onnx", "wb") as f:
     f.write(onx.SerializeToString())

#make predictions on test data
sess = rt.InferenceSession("pipeline_emails.onnx")
pred_onx = sess.run(None, {"str_input": test_df.as_matrix()})[0]
print("predict", pred_onx[0])
print("predict_proba", pred_onx[1])
'''

我希望得到一组关于我的测试数据的预测,但我得到:

代码语言:javascript
复制
RuntimeError                              Traceback (most recent call last)
<ipython-input-118-5db056b989a8> in <module>()
      2 sess = rt.InferenceSession("pipeline_emails.onnx")
      3 inputs = {'str_input': test_df.as_matrix()}
----> 4 pred_onx = sess.run(None, {"str_input": test_df.as_matrix()})[0]
      5 print("predict", pred_onx[0])
      6 print("predict_proba", pred_onx[1])

~\AppData\Local\Continuum\anaconda3\lib\site-packages\onnxruntime\capi\session.py in run(self, output_names, input_feed, run_options)
     70         if not output_names:
     71             output_names = [output.name for output in self._outputs_meta]
---> 72         return self._sess.run(output_names, input_feed, run_options)
     73 
     74     def end_profiling(self):

RuntimeError: Method run failed due to: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Missing required input: float_input
EN

回答 1

Stack Overflow用户

发布于 2019-06-04 09:43:23

错误消息清楚地显示“缺少必需的输入:float_input”。你正在传递“str_input”。此外,在提交问题时,请遵循https://github.com/microsoft/onnxruntime/issues/new?template=bug-performance-issue.md中的指南。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100006907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档