exportONNXNetwork works but importONNXNetwork can't load input layer

조회 수: 10 (최근 30일)
Luke Hubbard
Luke Hubbard 2023년 2월 22일
댓글: Luke Hubbard 2023년 2월 23일
I'm training a sequence classification network with lstms similar to the ClassifySequenceDataUsingLSTMNetworksExample and then exporting the trained model as an ONNX model for use in python. I have found that if I train the model with XTrain being cells of sequences, the network that is produced
1-will export without complaint with exportONNXNetwork
2-will NOT import to python
3-will NOT import back into Matlab via importONNXNetwork. matlab complaint is "Unable to create an ouput layer for ONNX network output #1 ... because its data format is unkown or not supported as a MATLAB output layer. If you know the output format, pass it using the 'outputDataFormats' parameter."
To get the complaint in 3- I added the following in the example live script after line 45:
exportONNXNetwork(net,onnxFilename)
importONNXNetwork(onnxFilename)
The python loading error is similar to the matlab error in that the layer input tensor rank (similar to data format) is incorrect
I have successfully exported and imported a lstm network to/from onnx format. But in that case, I trained with a datastore vs in this example the training inputs are cell arrays. Don't understand why that would change the onnx export/import outcome.
  댓글 수: 1
Luke Hubbard
Luke Hubbard 2023년 2월 23일
Looking at some previous examples where I was successfully able to export and import onnx models I noticed that the successful ones were all seriesNetworks while the ones I have trouble with are all DAGNetworks, and they were trained with R2021b vs R2022b. Maybe there's something going on there. What causes a network to be output as a seriesNetwork vs DAGNetwork?

댓글을 달려면 로그인하십시오.

답변 (1개)

Tamir Suliman
Tamir Suliman 2023년 2월 23일
All i can say based on your description, it seems like the issue may be related to the input data format or rank of the exported ONNX model, which is causing errors during the import process.
  댓글 수: 1
Luke Hubbard
Luke Hubbard 2023년 2월 23일
Exactly what I think. Somehow, when the network is trained with in-memory data vs out-of-memory datastores, that property does not get set correctly somewhere during the export process. I would like to know if there's a property I can set in the trained network (in this case a DAGNetwork) so that the format of input/output layers is properly set in exportONNXNetwork.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by