Main Content

rlTD3AgentOptions

Options for TD3 agent

Description

Use an rlTD3AgentOptions object to specify options for twin-delayed deep deterministic policy gradient (TD3) agents. To create a TD3 agent, use rlTD3Agent

For more information see Twin-Delayed Deep Deterministic Policy Gradient Agents.

For more information on the different types of reinforcement learning agents, see Reinforcement Learning Agents.

Creation

Description

opt = rlTD3AgentOptions creates an options object for use as an argument when creating a TD3 agent using all default options. You can modify the object properties using dot notation.

example

opt = rlTD3AgentOptions(Name,Value) sets option properties using name-value pairs. For example, rlTD3AgentOptions('DiscountFactor',0.95) creates an option set with a discount factor of 0.95. You can specify multiple name-value pairs. Enclose each property name in quotes.

Properties

expand all

Noise model options, specified as a GaussianActionNoise object or an OrnsteinUhlenbeckActionNoise object. For more information on noise models, see Noise Models.

For an agent with multiple actions, if the actions have different ranges and units, it is likely that each action requires different noise model parameters. If the actions have similar ranges and units, you can set the noise parameters for all actions to the same value.

For example, for an agent with two actions, set the variance of each action to a different value while using the same decay rate for both variances.

opt = rlTD3AgentOptions;
opt.ExplorationModel.Variance = [0.1 0.2];
opt.ExplorationModel.VarianceDecayRate = 1e-4;

Target smoothing noise model options, specified as a GaussianActionNoise object. This model helps the policy exploit actions with high Q-value estimates. For more information on noise models, see Noise Models.

For an agent with multiple actions, if the actions have different ranges and units, it is likely that each action requires different smoothing noise model parameters. If the actions have similar ranges and units, you can set the noise parameters for all actions to the same value.

For example, for an agent with two actions, set the variance of each action to a different value while using the same decay rate for both variances.

opt = rlTD3AgentOptions;
opt.TargetPolicySmoothModel.Variance = [0.1 0.2];
opt.TargetPolicySmoothModel.VarianceDecayRate = 1e-4;

Number of steps between policy updates, specified as a positive integer.

Smoothing factor for target actor and critic updates, specified as a positive scalar less than or equal to 1. For more information, see Target Update Methods.

Number of steps between target actor and critic updates, specified as a positive integer. For more information, see Target Update Methods.

Flag for clearing the experience buffer before training, specified as a logical value.

Flag for saving the experience buffer data when saving the agent, specified as a logical value. This option applies both when saving candidate agents during training and when saving agents using the save function.

For some agents, such as those with a large experience buffer and image-based observations, the memory required for saving their experience buffer is large. In such cases, to not save the experience buffer data, set SaveExperienceBufferWithAgent to false.

If you plan to further train your saved agent, you can start training with the previous experience buffer as a starting point. In this case, set SaveExperienceBufferWithAgent to true.

Size of random experience mini-batch, specified as a positive integer. During each training episode, the agent randomly samples experiences from the experience buffer when computing gradients for updating the critic properties. Large mini-batches reduce the variance when computing gradients but increase the computational effort.

Number of future rewards used to estimate the value of the policy, specified as a positive integer. See [1], (Chapter 7), for more detail.

Experience buffer size, specified as a positive integer. During training, the agent updates the actor and critic using a mini-batch of experiences randomly sampled from the buffer.

Sample time of agent, specified as a positive scalar.

Within a Simulink environment, the agent gets executed every SampleTime seconds of simulation time.

Within a MATLAB environment, the agent gets executed every time the environment advances. However, SampleTime is the time interval between consecutive elements in the output experience returned by sim or train.

Discount factor applied to future rewards during training, specified as a positive scalar less than or equal to 1.

Object Functions

rlTD3AgentTwin-delayed deep deterministic policy gradient reinforcement learning agent

Examples

collapse all

This example shows how to create a TD3 agent option object.

Create an rlTD3AgentOptions object that specifies the mini-batch size.

opt = rlTD3AgentOptions('MiniBatchSize',48)
opt = 
  rlTD3AgentOptions with properties:

                       ExplorationModel: [1x1 rl.option.GaussianActionNoise]
                TargetPolicySmoothModel: [1x1 rl.option.GaussianActionNoise]
                  PolicyUpdateFrequency: 2
                     TargetSmoothFactor: 0.0050
                  TargetUpdateFrequency: 2
    ResetExperienceBufferBeforeTraining: 1
          SaveExperienceBufferWithAgent: 0
                          MiniBatchSize: 48
                    NumStepsToLookAhead: 1
                 ExperienceBufferLength: 10000
                             SampleTime: 1
                         DiscountFactor: 0.9900

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

opt.SampleTime = 0.5;

Algorithms

expand all

References

[1] Sutton, Richard S., and Andrew G. Barto. Reinforcement Learning: An Introduction. Second edition. Adaptive Computation and Machine Learning. Cambridge, Mass: The MIT Press, 2018.

Introduced in R2020a