我已将 LSTM 模型从 pytorch 导出到 onnx 。该模型采用长度为 200 的序列。它的隐藏状态大小为 256 ,层数 = 2。前向函数将输入大小 (batchs , sequencelength) 以及由隐藏状态和单元状态组成的元组作为输入。使用 onnx 运行时推断模型时出现错误。隐藏状态和单元状态维度相同。
ioio1 = np.random.rand(1,200)
ioio2 = np.zeros((2,1,256),dtype = np.float)
pred = runtime_session.run([output_name],{runtime_session.get_inputs()[0].name:ioio1,
runtime_session.get_inputs()[1].name :ioio2,
runtime_session.get_inputs()[2].name : ioio2})
InvalidArgument Traceback (most recent call last)
<ipython-input-204-3928823f661e> in <module>()
1 pred = runtime_session.run([output_name],{runtime_session.get_inputs()[0].name:ioio1,
2 runtime_session.get_inputs()[1].name :ioio2,
----> 3 runtime_session.get_inputs()[2].name : ioio2})
/usr/local/lib/python3.6/dist-packages/onnxruntime/capi/session.py in run(self, output_names, input_feed, run_options)
109 output_names = [output.name for output in self._outputs_meta]
110 try:
--> 111 return self._sess.run(output_names, input_feed, run_options)
112 except C.EPFail as err:
113 if self._enable_fallback:
InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (N11onnxruntime17PrimitiveDataTypeIdEE) , expected: (N11onnxruntime17PrimitiveDataTypeIlEE)