My ONNX network doesn't work when loaded in my Java application
Show older comments
Hi guys! I'm developping a Java application that uses a CNN, precisely an AlexNet. I followed these tutorials https://it.mathworks.com/matlabcentral/fileexchange/62990-deep-learning-tutorial-series , https://it.mathworks.com/help/deeplearning/ref/alexnet.html and https://it.mathworks.com/help/deeplearning/ref/trainnetwork.html . Now a weird thing occurs: I generated the network with a high accuracy (96.5% on a dataset "never seen before", that comes from the environment that the network is thought to work on). Next, I loaded the model in my Java application, using the OpenCV method readNetFromONNX ( https://docs.opencv.org/master/javadoc/org/opencv/dnn/Dnn.html ) but the network completely misclassifies. It's not a wrong coding of the classes, it simply "randomly" classifies. The thing is that, if I generate (with the same code, and same dataset) a network with a lower accuracy, maybe with a bad choice of training parameters (I mean about 90%), it works fine when loaded (by "fine" I mean at 90%, obviously). I thought it was overtraining, and, in fact, I trained the network with the test set getting an accuracy of (surprise surprise) 99.89%, but when I load it on my Java application (where, some inputs coming from the test set are given) the same thing occurs, it completely missclassifies everything that come as input. It's like Java doesn't accept the network that has a high accuracy.
Accepted Answer
More Answers (1)
Luigi Treccozzi
on 11 Jul 2019
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!