How to change the dimensions of the original dataset to get the same forecast value? LTSM ONNX

19 次查看(过去 30 天)
I trained an LSTM model in matlab
The original data set is 56 * 3853
feature_dimension is 56
miniBatchSize = 50;
[net,YPred] = predictAndUpdateState(net,xtrain,'ExecutionEnvironment','cpu');
normal operation
then...
filename = "lstm.onnx";
exportONNXNetwork(net,filename)
save data.mat xtrain
in python...
import onnxruntime
onnx_model = onnxruntime.InferenceSession('lstm.onnx')
from scipy import io
mydata = io.loadmat('data.mat')
data=np.float32(mydata['xtrain'])
onnx_input = {onnx_model.get_inputs()[0].name: data}
outputs = onnx_model.run(None, onnx_input)
InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: input Got: 2 Expected: 3 Please fix either the inputs or the model.
How to change the dimensions of the original dataset to get the same forecast value? LTSM ONNX
thanks a lot !!!

采纳的回答

Sivylla Paraskevopoulou
You should permute from the MATLAB ordering (CN) to the ONNX ordering (NC), where C is the number of features and N is the number of sequence observations. Permute the input data before saving them to data.mat.
xtrain = permute(xtrain,[2,1]);
For more information about dimension ordering for different deep learning platforms, see Input Dimension Ordering.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by