How to generate code from a trained LSTM network using MATLAB/Simulink?

조회 수: 22(최근 30일)
Is code generation from a trained LSTM network supported, and if so, how? There appear to be different approaches to generate code from a trained LSTM network while working without/with Simulink.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2021년 9월 30일
편집: MathWorks Support Team 2021년 9월 30일

1. Generate code from a trained LSTM network using MATLAB

In order to generate code from a trained LSTM network using MATLAB, there are different approaches:
(a) Generate C/C++ code using MATLAB Coder:
From MATLAB R2020a onwards, you can generate code for ARM Cortex-A CPUs. Refer to the blog post below on how to get started with deep learning models on ARM Cortex-A with MATLAB:
From MATLAB R2020b onwards, you can generate C++ code for an LSTM network, a stateful LSTM network, or a bidirectional LSTM network that uses the Intel® MKL-DNN library.
(b) Generate CUDA code using GPU Coder:
From R2019b onwards, you can generate code for NVIDIA GPUs. See the following documentation link for more information:

 

2. Generate code from a trained LSTM network using Simulink

From R2020b onwards, using MATLAB Coder or GPU Coder, you can use coder.loadDeepLearningNetwork and other associated functions to run inference in a MATLAB Function block. This will support accelerated simulation and code generation for both CPU or GPU targets. The following link illustrates the workflow:

추가 답변(2개)

NGR MNFD
NGR MNFD 2021년 7월 2일
Hello . I hope you have a good day. I sent the article to your service. I implemented the coding part in the MATLAB software, but to implement my network, two lines of setlayers, training MATLAB 2014 give me an error. What other function do you think I should replace? Do you think the codes I wrote are correct?( I used gait-in-neurodegenerative-disease-database in physionet website.) Thanks a lot

NGR MNFD
NGR MNFD 2021년 7월 4일
hello dear .No, a trained lstm network is not supported and it is just lstm coding on data without simulink. Did I understand your question correctly?Thank you for your help. But boldly, I want to run this code inside MATLAB 2014. What command or function should I add to it? Because my laptop model is low and hangs by installing a higher version.No, a trained lstm network is not supported and it is just lstm coding on data without simulink. Did I understand your question correctly?thanks

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by