Error when trying to export a trained deep learning model to ONNX format in MATLAB due to the "SplitComplexInputs"
12 次查看(过去 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?
0 个评论
采纳的回答
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" :
You can also refer to the answer below where a similar query has been addressed. https://in.mathworks.com/matlabcentral/answers/1995283-export-trained-classification-model-from-classification-learner-to-use-in-python
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 Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!