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

19 visualizaciones (últimos 30 días)
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 !!!

Respuesta aceptada

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou el 18 de Nov. de 2022
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.

Más respuestas (0)

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by