Code generation of a trained reinforcement learning agent

12 views (last 30 days)
i want to integrate a trained reinforcement learning agent to a microcontroller.
The training takes place in simulink.
The microcontroller only has a single precision FPU.
How do I setup the agent, that the agent uses single precision and not double presicion, especially if the observations are also of the single data type?

Accepted Answer

Sayan Saha
Sayan Saha on 7 Mar 2022
Hi Allmo,
Since you are targeting a micro-controller to deploy code you can generate plain C/C++ code from the trained RL agent following the approaches in You'll have to use the library-free deep learning configuration object to generate plain C/C++ code as mentioned in :
dlconfig = coder.DeepLearningConfig(TargetLibrary='none');
While the input data to the entry-point function can be of non-single type, the data will always be casted to single precision before invoking the inference method on the network. You can specify the input data to be of single precision so that generated code will only have single precision data without any typecasting.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!