How to export and use only the end product of a reinforcement learning algorithm ?


I have used reinforcement learning to train a TD3 agent. Now I want to use this agent and actually deploy it as a controller in a simulink model, then possibly on an embedded platform. From what I understand about reinforcement learning, the actor network is the actual end product which computes the control action. Therefore, I don’t want to export everything else with it as a RL agent representation, just the neural net. Is there something I should be wary of when doing this ? Also what simulink block can I use for a deep NN controller ? I am not sure if the predict block is suitable here as the task is not classification and the output should be an action, rather than likelihood percentages.

Also, I have created a TD3 agent with LSTM layers on MATLAB R2021a. When I try to import the agent to R2020b, which it is incompatible with, the agent surprisingly does get imported but when I try to simulate it to validate the results I get very different ones from when I try to do it on R2021a. Are the LSTM layers inside of the agent not working properly in R2020b or are they completely incompatible (for simulating the agent only, not training) ? Would doing something I described above (importing only the neural net as a controller) allow me to use the network as a controller on older versions of MATLAB?

ANSWER provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

To deploy trained RL agent you need to:

  • Extract trained policy from RL agent. For that you use generatePolicyFunction. As the doc explains, this function will create a function evaluatePolicy.m and agentData.mat file.
  • To run inference on trained policy in Simulink, use MATLAB Function block in Simulink. In MATLAB Funciton block call evaluatePolicy
  • You are done! You can now simulate your trained policy in Simulink. Starting with 21a we support ANSI C code gen for deep learning networks. So you can generate ANSI C code from your Simulink model that contains whetever algorithms you have plus trained RL policy represented by MATLAB Function Block.
  • The generated code should be compatible with any microcontroller, or with a rapid prototyping setup, for example, with speedgoat machine.

To see the details on what layers currently support ANSI C (generic C),

As for the second question, T3D support for LSTMs came in 21a in Reinforcement Learning Toolbox. So as you point out you would not be able to use this agent in 20b. However,





Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to automate electron microscopic image analysis?

Recognizing Handwritten Digits

Build an Abstractive Text Summarizer in 94 Lines of Tensorflow !! (Tutorial 6)

Training YOLOv3 for detecting vehicles on video from scratch

Recent good papers (August 2020)

TensorFlow- Most Famous Deep Learning Library

eBay Makes Search More Efficient Through Personalization

QC Ware Explores Using Quantum Neural Networks to Improve Biomedical Image Analysis with Roche

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

More from Medium

Applying Machine Learning to Predict the Market Cap Of Some Layer 1s Based On Total Value Locked…

Creating AI Art? Has your Super-SloMo model stopped working?

Browsers are using federated learning to show targeted ads in a post cookie world

How Federated Learning advanced COVID-19 diagnosis