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
creates a default
option set for an ac agent. you can modify the object properties using dot
notation.opt
= rlacagentoptions
creates the options set opt
= rlacagentoptions(name=value
)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
numstepstolookahead
— number of steps ahead
32
(default) | positive integer
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
entropylossweight
— entropy loss weight
0
(default) | scalar value between 0
and 1
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
actoroptimizeroptions
— actor optimizer options
rloptimizeroptions
object
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)
criticoptimizeroptions
— critic optimizer options
rloptimizeroptions
object
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)
sampletime
— sample time of agent
1
(default) | positive scalar | -1
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
discountfactor
— discount factor
0.99
(default) | positive scalar less than or equal to 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
rlacagent | actor-critic (ac) reinforcement learning agent |
examples
create ac agent options object
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;
configure options for a3c training
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 r2019ar2022a: simulation and deployment: usedeterministicexploitation
will be removed
the property usedeterministicexploitation
of the
rlacagentoptions
object will be removed in a future release. use the
useexplorationpolicy
property of rlacagent
instead.
previously, you set usedeterministicexploitation
as follows.
force the agent to always select the action with maximum likelihood, thereby using a greedy deterministic policy for simulation and deployment.
agent.agentoptions.usedeterministicexploitation = true;
allow the agent to select its action by sampling its probability distribution for simulation and policy deployment, thereby using a stochastic policy that explores the observation space.
agent.agentoptions.usedeterministicexploitation = false;
starting in r2022a, set useexplorationpolicy
as follows.
force the agent to always select the action with maximum likelihood, thereby using a greedy deterministic policy for simulation and deployment.
agent.useexplorationpolicy = false;
allow the agent to select its action by sampling its probability distribution for simulation and policy deployment, thereby using a stochastic policy that explores the observation space.
agent.useexplorationpolicy = true;
similarly to usedeterministicexploitation
,
useexplorationpolicy
affects only simulation and deployment; it does
not affect training.
r2020b: default value for numstepstolookahead
changed to 32
a value of 32 for this property should work better than 1 for most environments. if you
nave matlab r2020b or a later version and you want
to reproduce how rlacagent
behaved on
versions prior to r2020b, set this value to 1.
打开示例
您曾对此示例进行过修改。是否要打开带有您的编辑的示例?
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 matlab 命令。
select a web site
choose a web site to get translated content where available and see local events and offers. based on your location, we recommend that you select: .
you can also select a web site from the following list:
how to get best site performance
select the china site (in chinese or english) for best site performance. other mathworks country sites are not optimized for visits from your location.
americas
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)