Error when trying to export a trained deep learning model to ONNX format in MATLAB due to the "SplitComplexInputs"

4 ビュー (過去 30 日間)
I followed the tutorial on MATLAB's official website for modulation classification using deep learning:
After training the network, I attempted to export the trained model to ONNX using the following command:
exportONNXNetwork(trainedNet, "www.onnx");
However, I received the following error message:
Error using nnet.internal.cnn.onnx.ConverterForSequenceInputLayer/toOnnx (line 55)
Unsupported input layer option for layer 'Input Layer'. To export networks with an
input layer, the SplitComplexInputs property must be 0 (false).
Error in nnet.internal.cnn.onnx.ConverterForNetwork/networkToGraphProto (line 109)
= toOnnx(layerConverter, nodeProtos, TensorNameMap, TensorLayoutMap);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in nnet.internal.cnn.onnx.ConverterForNetwork/toOnnx (line 45)
modelProto.graph = networkToGraphProto(this);
^^^^^^^^^^^^^^^^^^^^^^^^^
Error in nnet.internal.cnn.onnx.exportONNXNetwork (line 22)
modelProto = toOnnx(converter);
^^^^^^^^^^^^^^^^^
Error in exportONNXNetwork (line 44)
nnet.internal.cnn.onnx.exportONNXNetwork(Network, filename, varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It seems that my network's input layer has the SplitComplexInputs property set to true, which prevents ONNX export. How can I modify the network to allow exporting it in ONNX format for use in Python?

採用された回答

NVSL
NVSL 2025 年 2 月 19 日
編集済み: NVSL 2025 年 2 月 19 日
Hi @TK
I was able to reproduce the issue. The “SplitComplexInputs” flag is set to true if input data needs to be split into real and imaginary parts. It can be found at “trainedNet.Layers(1).SplitComplexInputs”. As the “trainedNet” is a pre-trained model, you cannot unset this flag.
A workaround is to save the MATLAB model and load it in Python using the "scipy.io" library:
import scipy.io
mat = scipy.io.loadmat('trainedNet.mat')
You can refer to the below link for more details and examples related to "scipy.io.loadmat" :
Alternately, you can inspect the properties of trainedNet through command window for its architecture and design your own CNN and train it with “SplitComplexInputs” set to false. This helps you in generating model exportable to onnx.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by