Matlab CNN model to ONNX - Inference Image Classification Results
Show older comments
Hello all,
I used 'exportONNXNetwork(net,filename)' function to export a fine-tuned CNN .mat model (mobilenet pretrained and fine-tuned on new dataset) to .onnx model.
When using the .onnx model in image classification inference I am getting wrong classification results. I compared the results that I am getting from Matlab inference with ONNX inference, it is not the same although the model was well exported and I checked some of the weights and biases of the network.
Does I need to make any additional conversion ? Is there any difference between the two models (I think the input is of shape 3*224*224 in ONNX instead of 224*224*3 in Matlab) ?
Thank you in advance. Appreciate your help!
1 Comment
PARVEZ
on 20 Oct 2025
Same problem for me too what to do to correct this problem please help
Answers (2)
xingxingcui
on 4 Aug 2021
0 votes
yes , you are correct, in onnnx file the input is of shape BatchSize*3*224*224 instead of 224*224*3*BatchSize in Matlab,
1 Comment
Andrea Daou
on 4 Aug 2021
Sivylla Paraskevopoulou
on 9 May 2022
0 votes
The Inference Comparison Between ONNX and Imported Networks for Image Classification example shows how to compare image classification results between an ONNX model and a Deep Learning Toolbox network.
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!