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 !!!
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!