main content

options for ac agent -凯发k8网页登录

options for ac agent

since r2019a

description

use an rlacagentoptions object to specify options for creating actor-critic (ac) agents. to create an actor-critic agent, use rlacagent

for more information see actor-critic (ac) agents.

for more information on the different types of reinforcement learning agents, see reinforcement learning agents.

creation

description

opt = rlacagentoptions creates a default option set for an ac agent. you can modify the object properties using dot notation.

example

opt = rlacagentoptions(name=value) creates the options set opt and sets its properties using one or more name-value arguments. for example, rldqnagentoptions(discountfactor=0.95) creates an options set with a discount factor of 0.95. you can specify multiple name-value arguments.

properties

number of steps the agent interacts with the environment before learning from its experience, specified as a positive integer. when the agent uses a recurrent neural network, numstepstolookahead is treated as the training trajectory length. when the agent is trained in parallel, numstepstolookahead is ignored, and the whole episode is used to compute the gradients.

example: numstepstolookahead=64

entropy loss weight, specified as a scalar value between 0 and 1. a higher entropy loss weight value promotes agent exploration by applying a penalty for being too certain about which action to take. doing so can help the agent move out of local optima.

when gradients are computed during training, an additional gradient component is computed for minimizing this loss function.

example: entropylossweight=0.01

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)

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

rlacagentactor-critic (ac) reinforcement learning agent

examples

create an ac agent options object, specifying the discount factor.

opt = rlacagentoptions(discountfactor=0.95)
opt = 
  rlacagentoptions with properties:
                sampletime: 1
            discountfactor: 0.9500
         entropylossweight: 0
     actoroptimizeroptions: [1x1 rl.option.rloptimizeroptions]
    criticoptimizeroptions: [1x1 rl.option.rloptimizeroptions]
       numstepstolookahead: 32
                infotosave: [1x1 struct]

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

opt.sampletime = 0.5;

to train an agent using the asynchronous advantage actor-critic (a3c) method, you must set the agent and parallel training options appropriately.

when creating the ac agent, set the numstepstolookahead value to be greater than 1. common values are 64 and 128.

agentopts = rlacagentoptions(numstepstolookahead=64);

use agentopts when creating your agent. alternatively, create your agent first and then modify its options, including the actor and critic options later using dot notation.

configure the training algorithm to use asynchronous parallel training.

trainopts = rltrainingoptions(useparallel=true);
trainopts.parallelizationoptions.mode = "async";

you can now use trainopts to train your ac agent using the a3c method.

for an example on asynchronous advantage actor-critic agent training, see train ac agent to balance cart-pole system using parallel computing.

version history

introduced in r2019a
网站地图