- It is not possible to generate code for 1d CNNs or any other 1d layers currently with the coder products.
- In terms of a workaround to use 2d CNNs with 1d sequence data, we have an example that showcases that workflow for audio signals: https://www.mathworks.com/help/deeplearning/ug/deep-learning-speech-recognition.html The main idea is to convert the audio signal to an auditory spectogram image, so that the 2d CNNs can process that image representing the original 1d signal data. Depending on what data you have, a similar approach can be taken to convert the 1d data to equivalent 2d data to feed to 2d CNNs.
C Code Generation for 1D CNN networks using CMSIS-NN
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Marisa Ehemann
il 5 Mag 2022
Commentato: Marisa Ehemann
il 15 Mag 2022
Hello,
since R2022a the CMSIS-NN library is available for C code generation. I am currently trying to generate C code from 1D CNNs for timeseries classification with the Matlab Coder App and run the generated code on a STM32F427. However, the CMSIS Library seems to support only LSTM Networks (tested with the coder.getDeepLearningLayers(TargetLibrary = 'cmsis-nn') command) but neither 1D nor 2D Convolution Layers.
Also i did find this instruction on how to build the CMSIS-NN library. I was able to follow all steps, but i don't really know how to proceed further with the resulting files. Since the title refers to C++ and the instruction itself only refers to C Code i am not sure whether this is the right solution to my problem.
So my questions are:
- Is it currently possible to generate C-Code from 1D CNNs (with or without CMSIS-NN)?
- If not, how should a workaorund with 2D CNN (with 1D sequence input) look like?
- If no solution is available for C, would it help to switch to C++ and embed the generated C++ code into the main C project?
Thank you very much!
Marisa
0 Commenti
Risposta accettata
Sayan Saha
il 12 Mag 2022
Hi Marisa,
Please find the answers to your questions below:
I am however curious to know why you want to use 1d CNNs? Does using lstmLayer/bilstmLayer/gruLayer not provide good results? While CMSIS-NN library only supports lstmLayer currently amongst the three mentioned above, you can generate plain C-code without using any libraries utilizing the "none" targetLibrary and deploy the generated code to STM32F427 board. Here is an example for that workflow: https://www.mathworks.com/help/coder/ug/generate-code-for-lstm-network-and-deploy-on-cortex-m.html Library-free codegeneration supports a wider range of layers as compared to CMSIS-NN library. You can invoke coder.getDeepLearningLayers("TargetLibrary", "none") to get the list of all supported layers.
3. It is a typo that mentions "C++" in the build steps of "CMSIS-NN" library. The library only supports "C" code. We will fix the post soon. Thank you for bringing this issue to our attention.
Hope this helps!
~Sayan
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!