Policy Deployment
Once you train a reinforcement learning agent, you can generate code to deploy the optimal policy. For example, using MATLAB® Coder™ and GPU Coder™, you can generate C++ or CUDA® code and deploy neural network policies on embedded platforms.
For an introduction to generating code from a policy, see Generate Code from Trained Reinforcement Learning Policies. For an introduction to training a deployed policy, see Examine Approaches to Fine Tune a Deployed Policy.
Functions
generatePolicyFunction | Generate MATLAB function that evaluates policy of an agent or policy object |
generatePolicyBlock | Generate Simulink block that evaluates policy of an agent or policy object (Since R2022b) |
policyParameters | Obtain structure of policy parameters to update policy during simulation or deployment (Since R2025a) |
updatePolicyParameters | Update policy according to structure of policy parameters given as input argument (Since R2025a) |
Blocks
| Policy | Reinforcement learning policy (Since R2022b) |
Topics
- Reinforcement Learning Workflow
Typical workflow you use to apply reinforcement learning to a problem.
- Generate Code from Trained Reinforcement Learning Policies
You can generate code for reinforcement learning agents using, for example, GPU Coder or MATLAB Coder.
- Examine Approaches to Fine Tune a Deployed Policy
Select the best approach to train a policy in the real world.
- Generate Policy Block for Deployment
Generate a policy block to deploy a trained policy.
- Train Policy Deployed on Raspberry Pi
Use
trainFromDatain a MATLAB learning loop to train a policy deployed on a Raspberry Pi board.

