Main Content

rlTD3AgentOptions

Options for TD3 agent

Since R2020a

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 (TD3) 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) creates the options set opt and sets its properties using one or more name-value arguments. For example, rlTD3AgentOptions(DiscountFactor=0.95) creates an option set with a discount factor of 0.95. You can specify multiple name-value arguments.

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 standard deviation of each action to a different value while using the same decay rate for both standard deviations.

opt = rlTD3AgentOptions;
opt.ExplorationModel.StandardDeviation = [0.1 0.2];
opt.ExplorationModel.StandardDeviationDecayRate = 1e-4;

To use Ornstein-Uhlenbeck action noise, first create a default OrnsteinUhlenbeckActionNoise object. Then, specify any nondefault model properties using dot notation.

opt = rlTD3AgentOptions;
opt.ExplorationModel = rl.option.OrnsteinUhlenbeckActionNoise;
opt.ExplorationModel.StandardDeviation = 0.05;

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 standard deviation of each action to a different value while using the same decay rate for both standard deviations.

opt = rlTD3AgentOptions;
opt.TargetPolicySmoothModel.StandardDeviation = [0.1 0.2];
opt.TargetPolicySmoothModel.StandardDeviationDecayRate = 1e-4;

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

Actor optimizer options, specified as an rlOptimizerOptions object. It allows you to specify training parameters of the actor approximator such as learning rate, gradient threshold, as well as the optimizer algorithm and its parameters. For more information, see rlOptimizerOptions and rlOptimizer.

Example: ActorOptimizerOptions = rlOptimizerOptions(LearnRate=2e-3)

Critic optimizer options, specified as an rlOptimizerOptions object. It allows you to specify training parameters of the critic approximator such as learning rate, gradient threshold, as well as the optimizer algorithm and its parameters. For more information, see rlOptimizerOptions and rlOptimizer.

Example: CriticOptimizerOptions = rlOptimizerOptions(LearnRate=5e-3)

Batch data regularizer options, specified as an rlBehaviorCloningRegularizerOptions object. These options are typically used to train the agent offline, from existing data. If you leave this option empty, no regularizer is used.

For more information, see rlBehaviorCloningRegularizerOptions.

Example: BatchDataRegularizerOptions = rlBehaviorCloningRegularizerOptions(BehaviorCloningRegularizerWeight=10)

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.

Example: TargetSmoothFactor=1e-2

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

Example: TargetUpdateFrequency=5

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

Example: ResetExperienceBufferBeforeTraining=true

Maximum batch-training trajectory length when using a recurrent neural network, specified as a positive integer. This value must be greater than 1 when using a recurrent neural network and 1 otherwise.

Example: SequenceLength=4

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.

Example: MiniBatchSize=128

Number of future rewards used to estimate the value of the policy, specified as a positive integer. Specifically, ifNumStepsToLookAhead is equal to N, the target value of the policy at a given step is calculated adding the rewards for the following N steps and the discounted estimated value of the state that caused the N-th reward. This target is also called N-step return.

Note

When using a recurrent neural network for the critic, NumStepsToLookAhead must be 1.

For more information, see [1], Chapter 7.

Example: NumStepsToLookAhead=3

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

Example: ExperienceBufferLength=1e6

Sample time of agent, specified as a positive scalar or as -1. Setting this parameter to -1 allows for event-based simulations.

Within a Simulink® environment, the RL Agent block in which the agent is specified to execute every SampleTime seconds of simulation time. If SampleTime is -1, the block inherits the sample time from its parent subsystem.

Within a MATLAB® environment, the agent is executed every time the environment advances. In this case, SampleTime is the time interval between consecutive elements in the output experience returned by sim or train. If SampleTime is -1, the time interval between consecutive elements in the returned output experience reflects the timing of the event that triggers the agent execution.

Example: SampleTime=-1

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

Example: DiscountFactor=0.9

Object Functions

rlTD3AgentTwin-delayed deep deterministic (TD3) policy gradient reinforcement learning agent

Examples

collapse all

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

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

                             SampleTime: 1
                         DiscountFactor: 0.9900
                       ExplorationModel: [1x1 rl.option.GaussianActionNoise]
                 ExperienceBufferLength: 10000
                          MiniBatchSize: 48
                         SequenceLength: 1
                  ActorOptimizerOptions: [1x1 rl.option.rlOptimizerOptions]
                 CriticOptimizerOptions: [1x2 rl.option.rlOptimizerOptions]
                    NumStepsToLookAhead: 1
                  PolicyUpdateFrequency: 2
                TargetPolicySmoothModel: [1x1 rl.option.GaussianActionNoise]
                     TargetSmoothFactor: 0.0050
                  TargetUpdateFrequency: 2
            BatchDataRegularizerOptions: []
    ResetExperienceBufferBeforeTraining: 0
                             InfoToSave: [1x1 struct]

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.

Version History

Introduced in R2020a

expand all