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

20 ビュー (過去 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
Sivylla Paraskevopoulou 2022 年 11 月 18 日
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 Center および File ExchangeSequence 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