rlPGAgent
Policy gradient reinforcement learning agent
Description
The policy gradient (PG) algorithm is a model-free, online, on-policy reinforcement learning method. A PG agent is a policy-based reinforcement learning agent that uses the REINFORCE algorithm to directly compute an optimal policy which maximizes the long-term reward. The action space can be either discrete or continuous.
For more information on PG agents and the REINFORCE algorithm, see Policy Gradient Agents. For more information on the different types of reinforcement learning agents, see Reinforcement Learning Agents.
Creation
Syntax
Description
Create Agent from Observation and Action Specifications
creates a policy gradient agent for an environment with the given observation and action
specifications, using default initialization options. The actor and critic in the agent
use default deep neural networks built from the observation specification
agent
= rlPGAgent(observationInfo
,actionInfo
)observationInfo
and the action specification
actionInfo
. The ObservationInfo
and
ActionInfo
properties of agent
are set to
the observationInfo
and actionInfo
input
arguments, respectively.
creates a policy gradient agent for an environment with the given observation and action
specifications. The agent uses default networks in which each hidden fully connected
layer has the number of units specified in the agent
= rlPGAgent(observationInfo
,actionInfo
,initOpts
)initOpts
object.
Policy gradient agents do not support recurrent neural networks. For more information on
the initialization options, see rlAgentInitializationOptions
.
Create Agent from Actor and Critic
creates a PG agent with the specified actor network. By default, the
agent
= rlPGAgent(actor
)UseBaseline
property of the agent is false
in
this case.
Specify Agent Options
creates a PG agent and sets the agent
= rlPGAgent(___,agentOptions
)AgentOptions
property to the agentOptions
input argument. Use this syntax after
any of the input arguments in the previous syntaxes.
Input Arguments
Properties
Object Functions
train | Train reinforcement learning agents within a specified environment |
sim | Simulate trained reinforcement learning agents within specified environment |
getAction | Obtain action from agent or actor given environment observations |
getActor | Get actor from reinforcement learning agent |
setActor | Set actor of reinforcement learning agent |
getCritic | Get critic from reinforcement learning agent |
setCritic | Set critic of reinforcement learning agent |
generatePolicyFunction | Create function that evaluates trained policy of reinforcement learning agent |
Examples
Tips
For continuous action spaces, the
rlPGAgent
agent does not enforce the constraints set by the action specification, so you must enforce action space constraints within the environment.