Main Content


Options for initializing reinforcement learning agents

Since R2020b


Use the rlAgentInitializationOptions object to specify initialization options for an agent. To create an agent, use the specific agent creation function, such as rlACAgent.



initOpts = rlAgentInitializationOptions returns a default options object for initializing a reinforcement learning agent that supports default networks. Use the initialization options to specify agent initialization parameters, such as the number of units for each hidden layer of the agent networks and whether to use a recurrent neural network.


initOpts = rlAgentInitializationOptions(Name=Value) creates the options set initOpts and sets its properties using one or more name-value arguments. You can specify multiple name-value arguments.


expand all

Number of units in each hidden fully connected layer of the agent networks, except for the fully connected layer just before the network output, specified as a positive integer. The value you set also applies to any LSTM layers.

Example: NumHiddenUnit=64

Flag to use recurrent neural network, specified as a logical.

If you set UseRNN to true, during agent creation the software inserts a recurrent LSTM layer with the output mode set to sequence in the output path of the agent networks. For more information on LSTM, see Long Short-Term Memory Neural Networks.


TRPO agents do not support recurrent networks.

Example: UseRNN=true

Object Functions

rlACAgentActor-critic (AC) reinforcement learning agent
rlPGAgentPolicy gradient (PG) reinforcement learning agent
rlDDPGAgentDeep deterministic policy gradient (DDPG) reinforcement learning agent
rlDQNAgentDeep Q-network (DQN) reinforcement learning agent
rlPPOAgentProximal policy optimization (PPO) reinforcement learning agent
rlTD3AgentTwin-delayed deep deterministic (TD3) policy gradient reinforcement learning agent
rlSACAgentSoft actor-critic (SAC) reinforcement learning agent
rlTRPOAgentTrust region policy optimization (TRPO) reinforcement learning agent


collapse all

Create an agent initialization options object, specifying the number of hidden neurons and use of a recurrent neural network.

initOpts = rlAgentInitializationOptions(NumHiddenUnit=64,UseRNN=true)
initOpts = 
  rlAgentInitializationOptions with properties:

    NumHiddenUnit: 64
           UseRNN: 1

You can modify the options using dot notation. For example, set the agent sample time to 0.5.

initOpts.NumHiddenUnit = 128
initOpts = 
  rlAgentInitializationOptions with properties:

    NumHiddenUnit: 128
           UseRNN: 1

To create your agent, use initOpts as an input argument of an agent constructor function.

Version History

Introduced in R2020b