exportONNXNetwork works but importONNXNetwork can't load input layer

11 ビュー (過去 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 Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by