Is there a way to C code a trained CNN to be used in a C/C++ program?
9 次查看(过去 30 天)
显示 更早的评论
Hi,
I was able to use and transfer learning from a pre-trained Convolutional Neural Network (CNN) following these two useful tutorials: https://www.mathworks.com/help/vision/examples/image-category-classification-using-deep-learning.html http://www.mathworks.com/help/nnet/examples/transfer-learning-using-convolutional-neural-networks.html
The generated object is a 1x1 SeriesNetwork, which is able to classify my set of images with good accuracy. However, I would like to C Code this CNN to use outside Matlab. According to the Neural Network toolbox, I can use the command genFunction to generate a Matlab function that simulate the trained neural network and then use codegen to generate a C/C++ code. However, if I try to call genFunction I receive the following error:
genFunction(convnet,'testConvNet')
Undefined function 'genFunction' for input arguments of type 'SeriesNetwork'.
My question is: Is there any other way to code this trained CNN to use it outside Matlab?
*P.S.: 1- I also used bagOfFeatures function to generate features for my image classification problem. Although the accuracy is not as good as the one obtained with a CNN, I have the same problem, as the generated classifier is an imageCategoryClassifier object. As far as I know, it is not supported by the C code tool. 2- There is a way to train a SVM classifier ( CompactClassificationECOC object), which is supported by the C coder. But because in these tutorials it use the features calculated by the CNN convolutional layers, I still need the CNN convolutional layers to make the SVM work.
I hope these details show that I did my homework before coming here. I have to admit my first contact with C coder tool was a week ago. Before I used to recode the application C after getting Matlab successful tests. Thanks.
2 个评论
Ram
2017-4-20
Can you describe how you are planning to integrate the generated code and deploy your application? what target platform do you have in mind for the generated code?
回答(1 个)
Swaroop Mishra
2017-1-31
This functionality to generate C/C++ code for a trained CNN does not seem to be present in the current version of MATLAB.
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!